LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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

Reply
 
Search this Thread
Old 08-26-2004, 12:33 PM   #1
thebover
Member
 
Registered: Jul 2004
Location: Canada
Distribution: suse 9.1/knoppix/slackware
Posts: 60

Rep: Reputation: 15
Angry 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!!!
 
Old 08-26-2004, 02:08 PM   #2
bruce ford
Member
 
Registered: Jul 2004
Location: Munich, Germany
Distribution: Sun Solaris 8, SuSE 9.0
Posts: 43

Rep: Reputation: 15
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
 
Old 08-26-2004, 02:11 PM   #3
thebover
Member
 
Registered: Jul 2004
Location: Canada
Distribution: suse 9.1/knoppix/slackware
Posts: 60

Original Poster
Rep: Reputation: 15
what is the purpose of the &?????
 
Old 08-26-2004, 02:30 PM   #4
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: ubuntu
Posts: 2,530

Rep: Reputation: 108Reputation: 108
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.
 
Old 08-26-2004, 02:42 PM   #5
thebover
Member
 
Registered: Jul 2004
Location: Canada
Distribution: suse 9.1/knoppix/slackware
Posts: 60

Original Poster
Rep: Reputation: 15
it works thanks guys!!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
bash script running as daemon Satriani Programming 12 03-29-2011 05:23 PM
Port Monitoring bash script twantrd Programming 15 01-29-2009 12:59 AM
Running two copy's of the same bash script AndiOliver Programming 2 10-06-2004 03:46 AM
small bash script to kill a PID flosch Linux - General 3 05-06-2004 09:28 PM
Running bash script files in C++ (Kylix) Acherion Programming 4 07-25-2003 11:35 PM


All times are GMT -5. The time now is 03:02 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration