On Wed, Jan 05, 2000 at 04:44:17PM -0800, Scott Tyson wrote:
> wait for that program to terminate and when it does wait X seconds then
> restart the program. So the script itself would run all the time making
> sure the program runs all the time.
Here's the short quick answer:
==============
#! /bin/bash
while true; do
/path/to/programName
sleep 10
done
==============
Here's the long fun logging ... like I use answer. The program below allows
me to kill the master process and it will clean up after the children. It also
logs a message anytime the children needs to be restarted.
Some minor changes have been made from the working versions I use... to hide
the evil things I'm actually doing with this script. So it _might_ not work.
You should only need to change the two lines that say "EDIT".
==============
#! /bin/bash
( echo "============================================================"
echo "`date` Master forward server starting: $$"
for l in program1 program2 program3 "prog4 -args"; do ### EDIT
echo -n "`date` Starting $l";
(
while sleep 30; do ### EDIT
$l 2>&1 &
trap "echo \"`date` Stopping $l... id $!\"; kill $!; exit 0" \
SIGHUP SIGINT SIGTERM;
echo "`date` Started $l... id $!";
wait;
echo "`date` Error $l... id $!";
trap - SIGHUP SIGINT SIGTERM;
done ) &
echo "... child id $!"
ID="$ID $!"
done
echo "`date` Setup trap for processes:" $ID
trap "echo \"`date` Stopping children...\" $ID; kill $ID; exit 0" SIGHUP SIGINT SIGTERM;
wait;
) >> ~/.log/proggies 2>&1 & ### EDIT
==============
****************************************************************************
* To UNSUBSCRIBE from the list, send a message with "unsubscribe lug-nuts"
* in the message body to majordomo@saclug.org. Please direct other
* questions, comments, or problems to lug-nuts-owner@saclug.org.
This archive was generated by hypermail 2b29 : Fri Feb 25 2000 - 14:29:09 PST