Supose I have a script "script1.sh" and I want to execute it as a daemon with nohup and &, and make it be "waiting" for a signal. How should I do that?
bash, the latest backround process' PID is stored in
nohup <command> & pid=$!
To send a process a signal you can use
kill -<signal> <pid>
Putting the pieces toghether, to start e.g. a background
watch -n1 echo foo process and send it e.g. a SIGTERM signal later:
nohup watch -n1 echo foo & pid=$! # ... kill -15 $pid