I have the following script which I run using the command:
./thescript.sh 2>&1 &
and if I kill the sub process spawned by it, after a few seconds it is restarted. Why is this?
thescript.sh:
#!/bin/bash
#...
#other stuff
#...
while true; do
nohup /usr/bin/php ../thing/script.php scriptargs >my_log.log 2>&1
/bin/mail -s "$SUBJECT" "me@home.com" < $EMAILMESSAGE
done
the result of
ps -ax | grep scriptargs
gives
19624 pts/0 S 0:00 /bin/bash ./thescript.sh
19643 pts/0 S 0:00 /usr/bin/php ../thing/script.php scriptargs
19771 pts/0 S+ 0:00 grep scriptargs
if I run
kill 19643
I get:
./thescript.sh: line 24: 19643 Terminated /usr/bin/php ../thing/script.php scriptargs >my_log.log 2>&1
but if then run:
ps -ax | grep scriptargs
again I get:
19624 pts/0 S 0:00 /bin/bash ./thescript.sh
19824 pts/0 S 0:00 /usr/bin/php ../thing/script.php scriptargs
19862 pts/0 S+ 0:00 grep scriptargs
I get the email - but then it respawns that process.
Why is this?