sequentially run the shell scripts.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting sequentially run the shell scripts.
# 1  
Old 09-19-2008
sequentially run the shell scripts.

Hi All,
I have a master script , which would run 4 scripts in sequence. When the first script gets executed , I need to check if a particular process has been completed. If it is completed , only then proceed with the second script.

This same rule applies to script3 and script4.

Can someone please help me out.This is the function that I wrote for the process check.

Code:
process_check ()
{
p1=`ps -ef | grep o1 |grep -v grep| wc -l`
if [ "$p1" = 0]
echo "Process not running"
return 0
else
echo "Process  completed"
return 1
}


Last edited by nua7; 09-19-2008 at 03:08 AM..
# 2  
Old 09-19-2008
Guys,
Please help...
# 3  
Old 09-19-2008
Please don't bump up questions, that's against our rules.

Use the wait command, have a read of the man page of wait.

Regards
# 4  
Old 09-19-2008
Quote:
Originally Posted by nua7
Hi All,
I have a master script , which would run 4 scripts in sequence. When the first script gets executed , I need to check if a particular process has been completed. If it is completed , only then proceed with the second script.

This same rule applies to script3 and script4.

Can someone please help me out.This is the function that I wrote for the process check.

Code:
process_check ()
{
p1=`ps -ef | grep o1 |grep -v grep| wc -l`
if [ "$p1" = 0]


You are missing then (as well as a space before ]):

Code:
if [ "$p1" = 0 ]
then

And you don't need two greps as well as wc:

Code:
if ps -ef | grep '[o]1'
then

Quote:
Code:
echo "Process not running"
return 0
else
echo "Process  completed"
return 1
}


Last edited by cfajohnson; 09-19-2008 at 03:49 AM..
# 5  
Old 09-19-2008
Thanks a lot!!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Log file is not updating when I run shell scripts scheduled thru crontab

Hi Forum, Good Day! I have created an empty html file wtih permissoin 777 created shell script(with permission 777) , code is below. #=======================start============== . /data09/oracle/apps_st/appl/D_oraapp095.env rm -rf /home/mnp/Test_log.txt echo... (1 Reply)
Discussion started by: kartheekbk
1 Replies

2. Shell Programming and Scripting

How to run scripts sequentially in background?

Hi , I have prepared the following shell script to run the hqls in background. These scripts are running Parallel but I want to run the hqls sequentially in background. cat >cc_script.ksh nohup hive -hiveconf rrdt=2016-06-12 -f /home/files/cust1.hql > home/log/cust1.log 2>&1 & nohup hive... (6 Replies)
Discussion started by: ROCK_PLSQL
6 Replies

3. Shell Programming and Scripting

Run 2 shell scripts simultaneously from one script

i Run 2 scripts on all of around 50 nodes every day. 1.Mod_1.sh 2.Mod_2.sh eg.. i run file with specific node no like Mod_1.sh NODE_(node number) Mod_2.sh NODE_(node number) I want to run both file by using single script with unique node number. Eg.. Mod_new.sh NODE_(node... (11 Replies)
Discussion started by: Ganesh Mankar
11 Replies

4. Shell Programming and Scripting

How to run scripts parallely inside shell script?

Hi , I have 4 scripts example script1,script2,script3,script4 . I have to run script1,script2 and script3 parallely since this 3 scripts dont have dependencies . Once script1,script2 and script3 got completed successfully , I have to trigger script4. Can someone help me on this how to... (10 Replies)
Discussion started by: vinothsekark
10 Replies

5. Shell Programming and Scripting

Help with how to run multiple script with concurrent processes runs sequentially.

Hi, The problem detail is follows I have three individual scripts . SCRIPT A sh -x sqoop_channels_nc_daily_01.sh & sh -x sqoop_channels_nc_daily_02.sh & sh -x sqoop_channels_nc_daily_03.sh SCRIPT B sh -x sqoop_contacts_nc_daily_01.sh & sh -x sqoop_contacts_nc_daily_02.sh & sh -x... (1 Reply)
Discussion started by: H_bansal
1 Replies

6. Shell Programming and Scripting

Shell script to run all the python scripts from particular directory

I have N number of python scripts which i am receiving from REST web server and i am saving them in /home/mandar/ . Now i want to write a script to run all the python scripts from this directory and monitor them every minute...if any process is dead or hung it should be restarted by this script. ... (0 Replies)
Discussion started by: Mandar Nandale
0 Replies

7. Shell Programming and Scripting

Run multiple python programs sequentially.

I HAVE WRITTEN NINE PYTHON CODES TO PERFORM A TASK ........ I WISH TO RUN THEM SEQUENTIALLY. eg. code1__code2 >>>>>>>>code9.py TO GET DESIRED OUTPUT. PLS HELP ME WRITTING SHELL SCRIPT .. I HAVE TO DISTRIBUTE THESE CODE FOR BEING USED BY OTHERS. (2 Replies)
Discussion started by: upvan111
2 Replies

8. Shell Programming and Scripting

Any scenario where a script will not run sequentially when called?

Can a script that calls another script exit and end while the called script is still running? If so, how can this be made to happen? (1 Reply)
Discussion started by: Harleyrci
1 Replies

9. UNIX for Dummies Questions & Answers

Run Processes Sequentially Using Process ID (PID)

Hi, I'm a newbie when it comes to using UNIX, and I'm hoping someone here can help me out. I have a set of processes that I want to run sequentially: process1.py process2.py process3.py I want to know I can run these sequentially using their process IDs (PIDs). Ideally, I want to... (2 Replies)
Discussion started by: shelata
2 Replies

10. Linux

Possible ways to run shell scripts on Windows

Hi all, I want to know possible ways to exceute the shell scripts on Windows environment. Please help me. Regards, Uday. (2 Replies)
Discussion started by: uday123
2 Replies
Login or Register to Ask a Question