- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Parallel jobs
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-22-2003 07:51 AM
тАО05-22-2003 07:51 AM
I have 4 shell scripts which has to start parallely (at same time).
I can put all the scripts in
cron and set same time to start running.
Is there any other method to do this? Which is the best method to do the same.
Raj
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-22-2003 07:57 AM
тАО05-22-2003 07:57 AM
Re: Parallel jobs
How about launching the scirpts in the background from one common script (cron'ed or otherwise).
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-22-2003 08:00 AM
тАО05-22-2003 08:00 AM
Re: Parallel jobs
#! /usr/bin/ksh
script1 & ; script2 & ; script3 & ; script4 &
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-22-2003 08:01 AM
тАО05-22-2003 08:01 AM
Re: Parallel jobs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-22-2003 08:51 AM
тАО05-22-2003 08:51 AM
SolutionThe typical approach is to have the parent process wat until all the child processes are finished and then let the parent exit. You then have an easy way of knowing that the jobs have finished without having to run ps'es.
#!/usr/bin/sh
myscript1.sh &
myscript2.sh &
myscript3.sh &
myscript4.sh &
wait
STAT=${?}
exit ${STAT}
The wait without arguments will pause until all the background tasks have finished.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-22-2003 09:43 AM
тАО05-22-2003 09:43 AM
Re: Parallel jobs
I want the process to wait until all (4) my process gets over and then send mail for me.
But just a "wait" will hold process until all background jobs to get over right.
There might be many more background process running on same server at same time.
So i guess my process will wait for all background process. AM i right ?
Then should i get PID for all jobs seperately and write sepearte wait also for each PID ?
Anybody got piece of code?
Requirement is
main.sh
scr1.sh &
scr2.sh &
scr3.sh &
scr4.sh &
wait untill above 4 process get over then
sendmail.sh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-22-2003 10:50 AM
тАО05-22-2003 10:50 AM
Re: Parallel jobs
The sample code Clay provided will accomodate your 'wait' until all background processes are done. If you want to get a bit more sophisticated consider this:
#!/usr/bin/sh
typeset LOG=/tmp/logger.$$
trap 'rm ${LOG}' EXIT
exec 1> ${LOG} 2>&1
{ sleep 3; cp; } &
PID1=$!
{ sleep 7; date; } &
PID2=$!
{ sleep 1; mv; } &
PID3=$!
wait ${PID1}; R1=$?; echo "PID1 was ${PID1} with return code=${R1}"
wait ${PID2}; R2=$?; echo "PID2 was ${PID2} with return code=${R2}"
wait ${PID3}; R3=$?; echo "PID3 was ${PID3} with return code=${R3}"
mailx -s "Test Results" root < ${LOG}
exit 0
As written the script runs three tasks in the background. Process-1 and process-3 will exit with a return code of <1> since they are written to fail. Process-2 will exit with a successful value of <0>.
The script itself can be executed in the background. All stdout and stderr from the processes are written to a file named uniquely with the parent pid ($$).
Upon completion, the script mails the output to 'root' and removes the temporary file of its results.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-22-2003 10:51 AM
тАО05-22-2003 10:51 AM
Re: Parallel jobs
#! /usr/bin/ksh
it runs in it's own shell. hence the wait command will wait for only the things that your script started to end.