I have a script that will track the process, and if this process dies, it will update it. I want script tracking to also kill the process if it was told to make script tracking a sigmor (e.g..). In other words, if I kill the tracking script, it should also kill the process that it is tracking, and not respawn and exit again.
Combining several messages (which, in my opinion, are best practices, for example, do not use a PID file), I get the following:
#!/bin/bash
DESC="Foo Manager"
EXEC="python /myPath/bin/FooManager.pyc"
trap "BREAK=1;pkill -HUP -P $BASHPID;exit 0" SIGHUP SIGINT SIGTERM
until $EXEC
do
echo "Server $DESC crashed with exit code $?. Restarting..." >&2
((BREAK!=0)) && echo "Breaking" && exit 1
sleep 1
done
So now, if I ran this script in one xterm. And then in another xterm I send a script something like:
kill -HUP <tracking_script_pid>
kill -TERM <tracking_script_pid>
script - . FooManager.pyc , SIGHUP SIGTERM. , , , , ?
.