Customized command excution


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Customized command excution
# 1  
Old 10-08-2015
Linux Customized command excution

Hi,

The below commands will be inside a KSH script and SOLARIS machine.
Code:
Command-1 //Executes in 10s,5s,..5mins,etc
TIMER  = Look for Command-1 execution status - IF finished in 25secs move to next command in the script IF NOT kill above command and move to next  command.
Command-2

Any suggestions
# 2  
Old 10-08-2015
Try
Code:
command-1 &
sleep 25
kill $!
command-2

If you want to eliminate the remote chance that command-1's PID ($!) has been reused in between, you may want to insert some process/command check before killing.
These 2 Users Gave Thanks to RudiC For This Post:
# 3  
Old 10-08-2015
I guess this should be working fine.
# 4  
Old 10-08-2015
In a shell with job control you can do
Code:
kill %1

and a reused PID won't be killed.
# 5  
Old 10-08-2015
There is no way that a Solaris system is going to recycle a PID in 30 seconds unless someone has changed the system's maximum PID to be artificially low to make it happen.
# 6  
Old 10-08-2015
Based on what configuration/setting the PID's are recycled in solaris and in other machines.
What will be the maximum time i can expect for some other process to use same PID?
# 7  
Old 10-09-2015
It isn't a question of time; it is a question of how many processes you are starting and how many are running at once.

When you boot the system, init becomes the 1st process started and it gets PID 1. The next process started gets PID 2, ... This continues until a process is assigned the highest PID the system will use (let's call it PID_MAX). Once that happens, it will start assigning PIDs in a loop again starting with 1 (but it will not assign a new process a PID that is still in use by an unreaped zombie or a by running process). I don't remember if Solaris actually has a kernel parameter named PID_MAX nor what its value is if it does exist, but the concept still applies. I would expect PID_MAX to be similar in range to INT_MAX (i.e., 2,147,483,647) on 64-bit hardware. On any Solaris system I've seen, you won't have a billion active processes and you won't be able to exec a billion processes in a minute (let alone 25 seconds); so you don't stand much of a chance of recycling a PID in this application.

On the other hand, if you have a process that may be running for weeks that spawns children on a system that may run for months between reboots, PID recycling should be considered.
This User Gave Thanks to Don Cragun For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Expext Script excution problem..

Hey Guys , iam trying to match to string in TCL scripts but it not working . Its only working true condition to print yes.. When condtion fail then even it prints YES Any suggestion this ?? if {} { puts"yes" ... (3 Replies)
Discussion started by: hackerdilli
3 Replies

2. Linux

clarification for cmd excution

Hi Code: nohup sar -u 10 $COUNT | awk 'NR>2 {$2=$4=$7="";}1' | tr -s ' ' '\t' 2>/dev/null >sar.out & i have execute above line from shell script .. but sar.out is created with ZERO bite size.. Help on that what is the problem here (1 Reply)
Discussion started by: Mani_apr08
1 Replies

3. Forum Support Area for Unregistered Users & Account Problems

customized username?

Hi i have registered but my username is set to default value ( my email). can i change this ? (2 Replies)
Discussion started by: customizeemai
2 Replies

4. Shell Programming and Scripting

Excution Problems with loading huge data content and convert it

Hi, I got long list of referred file content: CGTGCFTGCGTFREDG PEOGDKGJDGKLJGKL DFGDSFIODUFIODSUF FSDOFJSODIFJSIODFJ DSFSDFDFSDOFJFOSF SDFOSDJFOJFPPIPIOP . . . Input file content: >sample_1 SDFDSKLFKDSLSDFSDFDFGDSFIODUFIODSUFSDDSFDSSDFDSFAS (14 Replies)
Discussion started by: patrick87
14 Replies

5. Shell Programming and Scripting

parallel excution for 2000 files.

Hi, I have a function abc(). i am calling the function 9 times. it is working fine and completed the script execution 10 hours. input files: CUSTOMER_INFO_1111_12345.csv CUSTOMER_INFO_1222_12345.csv CUSTOMER_INFO_1322_12345.csv CUSTOMER_INFO_1333_12345.csv CUSTOMER_INFO_1151_12345.csv... (4 Replies)
Discussion started by: onesuri
4 Replies

6. Shell Programming and Scripting

Can nmon be customized?

Hi, my name is Steve Ngai from Malaysia. This is my first post. Hope to learn more about Unix from this forum. My first question is can nmon be customized? When I run nmon, I need to manually type c to see CPU usage, then m for memory usage. Can I pass it some nmon option to automatically see... (2 Replies)
Discussion started by: ngaisteve1
2 Replies

7. Shell Programming and Scripting

Customized copy.

HI guys, I'm working on a code with the following specs: 1. Retrieving files with a particular extensions from a location specified by the users. 2. Copying those files to user specified location i) but i need to pause copy if the network is busy ii) and the copy process must... (3 Replies)
Discussion started by: bill88
3 Replies

8. UNIX for Advanced & Expert Users

To find the time of excution of a particular unix command

Hi experts, It would be grateful if you can guide me on the following, 1.How to find the time of excution of a particular unix command. 2. How to find the terminal (IP Address) from where that particular unix command was excuted. 3. How to find the user who executed that particular unix... (1 Reply)
Discussion started by: apsprabhu
1 Replies

9. UNIX for Dummies Questions & Answers

xterm closing automatically after command excution

Hi, I have a commands in a file called commands.file, I am using this file with the following commnad xterm -e "commands.file" After executing this file in the new xterm, it is closing automatically. I want to use that xterm after that. Please help me regarding this? :) ... (4 Replies)
Discussion started by: chaitubek
4 Replies

10. Shell Programming and Scripting

mailing customized and formatted ls -lt command output

I'm trying to write a script to email the output of 'ls -lt' command that are 30 days old along with headers for eg. like owner, date, timestamp and a portion of some special character files like 'slfpay$/#:032508AA' in /home/test directory, I just want the numbers from the last field ($9), also... (3 Replies)
Discussion started by: mbak
3 Replies
Login or Register to Ask a Question