1

Keep process started from shell script when killing script

view story
linux-howto

http://unix.stackexchange.com – I have a restart script that kills a process, starts the process, sleeps for a while, then kills the process again, and so on. I want to be able to Strg + C the shell script when it's sleeping but still keep the created process around. I tried this (simplified): #!/bin/bash while true; do kill -SIGTERM $(pgrep foo) (foo &) sleep $((5*60*60)) done However, the PPID of process foo still points to the script's PID, so when I kill the script, I kill foo. Now I tried this: #!/bin/bash while true; do kill -SIGTERM $(pgrep foo) (foo &) & sleep $((5*60*60)) d (HowTos)