Script to check process completion


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Script to check process completion
# 1  
Old 03-26-2009
Script to check process completion

Hi,
OS - Unix

Iam doing the following:
after login to the unix box
1. change directory
2. run a shell script "preinstall.sh"
3. This takes apprx 5 mins
4. after which i use to change permission of a file "installhub.sh" (this file is generated from the previous step).

Is there anyway i can right a shell script to check when the "preinstall.sh" finishes or successfully finishes and then i go to the next step of changing permission for the file "installhub.sh"?

How to check if process is complete (successful or not)? (Here in this case for "preinstall.sh")

Another question - is "Sleep 5" command used in the scripts mean the process is suspended for 5 minutes or the process is running for say 4 minutes and i had given 5 minutes after which the next step will continue?

Any direction, so that i can pick up from there?

thanks
# 2  
Old 03-26-2009
preinstall.sh

if [[ $? -ne 0 ]]; then
echo "Program failed"
exit 2
fi

This will check whether the program has successfully end or not...
# 3  
Old 03-26-2009
Easiest way: change preinstall.sh to automatically change the permissions of installhub.sh
More complex way:
Code:
$ cat test1.sh
#!/usr/bin/ksh
sleep 10       # Sleep 10 seconds
echo "$0 done"
$
$ cat test2.sh
#!/usr/bin/ksh
echo "$0 done"
$
$ ./test1.sh &
[1] 10774
$ PID=$! ; while [ "$( ps -p $PID 2>&1 >/dev/null ; echo $? )" = "0" ]; do sleep 5; done ; ./test2.sh
./test1.sh done
[1]+  Done                    ./test1.sh
./test2.sh done
$

As for your other question: sleep halts the script for the given amount of seconds
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Issue with tracking successful completion of Child process running in background

Hello All, I am using Linux. I have two scripts: inner_script.ksh main_wrapper_calling_inner.ksh Below is the code snippet of the main_wrapper_calling_inner.ksh: #!/bin/ksh ppids=() ---> Main array for process ids. fppids=() ---> array to capture failed process ids. pcnt=0 --->... (5 Replies)
Discussion started by: dmukherjee
5 Replies

2. Shell Programming and Scripting

Script to check process status

Hi Team, I am using redhat 6.4 version server.We have a script which is used to check the process and sends email if the process is not running.If it is running it will continue and do some other operation. I didnot understand below option -z in the if condition.I have tried to... (5 Replies)
Discussion started by: muraliinfy04
5 Replies

3. Shell Programming and Scripting

How to determine the completion of a background process to trigger something else?

I've been thinking about a peculiar problem, and so far haven't been able to find out a convincing solution to that. To put it simply, I have a shell script (assume it to be parent_script.sh), calling another shell script (child_script.sh) 5 times, in nohup mode to be executed in the background.... (3 Replies)
Discussion started by: Aviktheory11
3 Replies

4. Shell Programming and Scripting

Check the file processed Completion

Hi, I have a wierd requirement where i need to check for a file transfered to my Server and once it is completed i need to start processing my jobs. My server is AIX 6.0 and i want to know is there some way in unix i can keep on checking the file and once it is completed successfully i can... (5 Replies)
Discussion started by: prasson_ibm
5 Replies

5. Shell Programming and Scripting

Script in KSH to check if a process its up or down.

Hi all! Im working on a simple script in KSH (just started) to check if a process its up or down, but im kind of lost with the following error. Script: #!/usr/bin/ksh psup=$(ps -ef | grep sftp | egrep -v grep | wc -l) if ($psup > 0); then echo "Process SFTP running" else ... (6 Replies)
Discussion started by: ARSport
6 Replies

6. Shell Programming and Scripting

Script to check running of process

Hi, Can anyone please tell me how to write a shell script to check whether a process if running or not.... if its still running then wait for sometime and if not then run the next query. Also, Under my one main script main.sh I have to run 2 scripts simutaneously which take some time to... (2 Replies)
Discussion started by: lovepujain
2 Replies

7. Shell Programming and Scripting

Challenging task : script for mailing process completion timing report to users.

Hi all, This is my first post. I am new to unix scripting. My requirement is as follows : We are using a financial backoffice application. Now at the end of day we have send users a status report stating all timings of EOD processes for all countries. I need timings for following... (0 Replies)
Discussion started by: ammbhhar
0 Replies

8. UNIX for Dummies Questions & Answers

Background Process Completion

I have my unix machine configured to run locate.updatedb on login in the background and after it completes, when I run a command such as ls-- the console returns the results of ls and + Done sudo /usr/libexec/locate.updatedbIs there... (3 Replies)
Discussion started by: Prodiga1
3 Replies

9. Shell Programming and Scripting

script to check if process is running

How do I make a shell script to see if a certain process is running. The process shows up on ps aux as /usr/sbin/daemon eg: if /usr/sbin/daemon else #nothin basically i want to run the process if it isnt running/ has been stopped. Thanks. (2 Replies)
Discussion started by: daydreamer
2 Replies

10. Shell Programming and Scripting

Check for FTP completion

Hello, I am sure a lot of you have come across this situation, and I want to know how you have or would handle this situation: - A file gets ftp'ed (import) regularly to a directory into our environment. Is there a way to check whether this file has completed ftp'ing. * I don't want my... (1 Reply)
Discussion started by: ChicagoBlues
1 Replies
Login or Register to Ask a Question