Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
08-26-2004, 12:33 PM
|
#1
|
Member
Registered: Jul 2004
Location: Canada
Distribution: suse 9.1/knoppix/slackware
Posts: 60
Rep:
|
bash script, monitoring running PID?
I need a script that starts a program (easy) then monitors that program and if it errors, or closes issues a shutdown now -h command.
first and last parts are easy. its the srcipt to monitor the running PID that i can't figure out!!!
|
|
|
08-26-2004, 02:08 PM
|
#2
|
Member
Registered: Jul 2004
Location: Munich, Germany
Distribution: Sun Solaris 8, SuSE 9.0
Posts: 43
Rep:
|
Hi,
use the shell builtin 'wait' for this task, e.g.
Code:
myprog &
if wait ${!}
then
echo program terminated
else
echo program terminated abnormally
fi
So long...
bruce
|
|
|
08-26-2004, 02:11 PM
|
#3
|
Member
Registered: Jul 2004
Location: Canada
Distribution: suse 9.1/knoppix/slackware
Posts: 60
Original Poster
Rep:
|
what is the purpose of the &?????
|
|
|
08-26-2004, 02:30 PM
|
#4
|
Senior Member
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536
Rep: 
|
To run the program in the background, so the script will continue while the program is running. In this case running the program in the background is really needed, because you want the wait command in the script to execute so it will do the monitoring you want.
|
|
|
08-26-2004, 02:42 PM
|
#5
|
Member
Registered: Jul 2004
Location: Canada
Distribution: suse 9.1/knoppix/slackware
Posts: 60
Original Poster
Rep:
|
it works thanks guys!!
|
|
|
All times are GMT -5. The time now is 12:48 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|