HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Scripting - jobs
Operating System - HP-UX
1842655
Members
2424
Online
110194
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- 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
07-12-2003 05:03 PM
07-12-2003 05:03 PM
Scripting - jobs
Hi,
My requirement is submitting multiple jobs say 8 jobs at the same time and get the exit status of those jobs and proceed based on exit status. To acheive just I am testing how to get exit status using small script.
#!/bin/ksh
job1() {
/tmp/t1.sh &
PID=`echo $!`
wait $PID
STATUS=`echo $?`
}
job1
sleep 7
echo $STATUS
cat /tmp/t1.sh
#!/bin/ksh
sleep 5
exit 0
This works fine as long as I am calling job1() in the foreground. If I change job1 ==> job1& I am not getting anything from $STATUS variable. Any help is appreciated.
Thanks.
My requirement is submitting multiple jobs say 8 jobs at the same time and get the exit status of those jobs and proceed based on exit status. To acheive just I am testing how to get exit status using small script.
#!/bin/ksh
job1() {
/tmp/t1.sh &
PID=`echo $!`
wait $PID
STATUS=`echo $?`
}
job1
sleep 7
echo $STATUS
cat /tmp/t1.sh
#!/bin/ksh
sleep 5
exit 0
This works fine as long as I am calling job1() in the foreground. If I change job1 ==> job1& I am not getting anything from $STATUS variable. Any help is appreciated.
Thanks.
Never quit
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2003 05:56 PM
07-12-2003 05:56 PM
Re: Scripting - jobs
Hi,
Once you put your job1 into background all of it's variables inside that function are unavailable to the current shell. So, you won't get anything to the STATUS variable current shell. Try this way. Exit the job1 code with the return code from t1.sh and capture it from the wait of job1.
#!/bin/ksh
job1() {
t1.sh &
PID=`echo $!`
wait $PID
STATUS=$?
exit $STATUS
}
job1 &
PID=`echo $!`
wait $PID
JOBSTATUS=$?
echo $JOBSTATUS
I hope you got the picture.
-Sri
Once you put your job1 into background all of it's variables inside that function are unavailable to the current shell. So, you won't get anything to the STATUS variable current shell. Try this way. Exit the job1 code with the return code from t1.sh and capture it from the wait of job1.
#!/bin/ksh
job1() {
t1.sh &
PID=`echo $!`
wait $PID
STATUS=$?
exit $STATUS
}
job1 &
PID=`echo $!`
wait $PID
JOBSTATUS=$?
echo $JOBSTATUS
I hope you got the picture.
-Sri
You may be disappointed if you fail, but you are doomed if you don't try
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2003 12:21 AM
07-13-2003 12:21 AM
Re: Scripting - jobs
Or add a line in job1 () like this:
echo "$PID\t$STATUS" >> /tmp/stats.list
and later view all $STATUS for all $PIDS as
you comfortable.
Zeev
echo "$PID\t$STATUS" >> /tmp/stats.list
and later view all $STATUS for all $PIDS as
you comfortable.
Zeev
So computers don't think yet. At least not chess computers. - Seymour Cray
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2003 12:20 PM
07-13-2003 12:20 PM
Re: Scripting - jobs
Hello!
You can made the job1 function as difrent
script and run it with & like you do in
your job1 for /tmp/t1.sh
Caesar
You can made the job1 function as difrent
script and run it with & like you do in
your job1 for /tmp/t1.sh
Caesar
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP