How to run scripts sequentially in background?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to run scripts sequentially in background?
# 1  
Old 10-10-2016
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.
Code:
cat >cc_script.ksh
nohup hive -hiveconf rrdt=2016-06-12 -f /home/files/cust1.hql > home/log/cust1.log 2>&1 &
nohup hive -hiveconf rrdt=2016-06-12 -f /home/files/cust2.hql > home/log/cust2.log 2>&1 &
nohup hive -hiveconf rrdt=2016-06-12 -f /home/files/cust3.hql > home/log/cust3.log 2>&1 &
nohup hive -hiveconf rrdt=2016-06-12 -f /home/files/cust4.hql > home/log/cust4.log 2>&1 &
ksh cc_script.ksh

Thanks in advance.

Moderator's Comments:
Mod Comment If you ignore using code tags, you will be banned soon.

Last edited by zaxxon; 10-10-2016 at 02:53 AM..
# 2  
Old 10-10-2016
Then, remove the nohups and & s and run the entire script in background.
# 3  
Old 10-10-2016
Hi,

Please help me how to run in background.

Thanks
# 4  
Old 10-10-2016
Did you not understand RudiC's post?
Let me help...
Code:
hive -hiveconf rrdt=2016-06-12 -f /home/files/cust1.hql > home/log/cust1.log 2>&1
hive -hiveconf rrdt=2016-06-12 -f /home/files/cust2.hql > home/log/cust2.log 2>&1
hive -hiveconf rrdt=2016-06-12 -f /home/files/cust3.hql > home/log/cust3.log 2>&1
hive -hiveconf rrdt=2016-06-12 -f /home/files/cust4.hql > home/log/cust4.log 2>&1

# 5  
Old 10-10-2016
@OP:
Please stop ignoring helpful answers and just stop repeating your demanding behaviour if it is not already presented in a way, that you can copy & paste it. This is very bad behaviour. You can always ask, if you don't understand something.
Start using your brain. This also involves communication and communication goes in both ways.

You will be banned if you don't change your behaviour.

cheers
zaxxon
This User Gave Thanks to zaxxon For This Post:
# 6  
Old 10-10-2016
Quote:
Originally Posted by ROCK_PLSQL
Hi,

Please help me how to run in background.

Thanks
As you have already been told, the obvious way to do that would be to change your script to:
Code:
hive -hiveconf rrdt=2016-06-12 -f /home/files/cust1.hql > home/log/cust1.log 2>&1
hive -hiveconf rrdt=2016-06-12 -f /home/files/cust2.hql > home/log/cust2.log 2>&1
hive -hiveconf rrdt=2016-06-12 -f /home/files/cust3.hql > home/log/cust3.log 2>&1
hive -hiveconf rrdt=2016-06-12 -f /home/files/cust4.hql > home/log/cust4.log 2>&1

and run your script with:
Code:
ksh cc_script.ksh&

If the backgrounding needs to be done inside your script, you could use:
Code:
{
hive -hiveconf rrdt=2016-06-12 -f /home/files/cust1.hql > home/log/cust1.log 2>&1
hive -hiveconf rrdt=2016-06-12 -f /home/files/cust2.hql > home/log/cust2.log 2>&1
hive -hiveconf rrdt=2016-06-12 -f /home/files/cust3.hql > home/log/cust3.log 2>&1
hive -hiveconf rrdt=2016-06-12 -f /home/files/cust4.hql > home/log/cust4.log 2>&1
}&
wait

and run your script with:
Code:
ksh cc_script.ksh

or:
Code:
ksh cc_script.ksh&

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Run scripts in background one by one

Hello all, Can someone help with one script? I have as example 3 scripts 1.sh sleep 60 & sleep 60 & sleep 10 & sleep 80 & sleep 60 & 2.sh sleep 40 & sleep 5 & sleep 10 & sleep 70 & sleep 60 & 3.sh (2 Replies)
Discussion started by: vikus
2 Replies

2. Shell Programming and Scripting

Running scripts in background

Hi, below is my master script wihch inturn runs 2 scripts in background #master_script.sh ./subscript1.sh & ./subscript2.sh & executed the master_script.sh from unix command prompt $ ./master_script.sh it is executing the subscripts and they are completing fine, however master_script.sh is... (2 Replies)
Discussion started by: JSKOBS
2 Replies

3. UNIX for Dummies Questions & Answers

Scripts can be run manually but couldn't run with cronjobs

I am from MQ/MB technology. My requirement is to display the queue manger and broker status on daily basis. If I manually run the script, it works fine and displays output. But when I have scheduled the same using cronjobs it shows only the queue manger status and not the broker status. Can... (3 Replies)
Discussion started by: Anusha M
3 Replies

4. 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

5. 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

6. 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

7. Shell Programming and Scripting

background scripts run-help

Looking for a logic where say i have a script called parent_script which is used to call other 4 to 5 child scripts in background as.. cat parent_script # containing 65 lines 1 2 .. 35 while read child_script 36 do 37 ./child_script_name& 38 done< ${SCRIPT_LISTS} 39 40 # Need to have... (2 Replies)
Discussion started by: michaelrozar17
2 Replies

8. Shell Programming and Scripting

Simutaneous scripts within a background task

Hi, I have a script that polls a directory using inotifywait. This script is always running in the background. Within that script, I have 2 commands that need to run simultaneously. When those scripts are finished, I have to fire off a 3rd. The problem is, the 3rd script is never being... (0 Replies)
Discussion started by: gseyforth
0 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. Shell Programming and Scripting

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... (4 Replies)
Discussion started by: nua7
4 Replies
Login or Register to Ask a Question