I have a script that is suppose to stop and recover the process to run in the background:
process_id=`ps -eaf | grep -i daemon | grep -v grep | grep -v status | grep -v stop | awk '{print $2}'`
(kill -STOP $process_id) &
... # do something else
(kill -CONT $process_id) &
This is working fine, but then in the STDOUT / STDERR this appears:
[1] + 8545 Suspended (signal) /etc/init.d/...
So far I tried to:
(kill -STOP $process_id)
(kill -STOP $process_id) & > /dev/null
/etc/init.d/{name_of_the_daemon} start > /dev/null
(kill -STOP $process_id & ) 2>/dev/null
(kill -STOP $process_id & disown;) 2>/dev/null
set +m
(kill -STOP $process_id) &
(kill -STOP $process_id) & 1>&2
These are the steps that I'm doing:
- create a file fff in
/etc/init.d/ - paste the script from below
chmod 755 fff- /etc/init.d/fff start
After that, I receive the "suspended" message...
According to @sourcejedi my script is not a daemon; when a child process of the script has been suspended, the "suspended" message appears
How can I suppress the output from the shell for only that particular message?
Here is a very simple version of my script:
#!/bin/bash
pid_script=`ps -eaf | grep -i fff | grep -v grep | grep -v status | grep -v stop | awk '{print $2}'`
case "$1" in
start)
( sleep 3; kill -STOP $pid_script ) &
sleep 10;
(sleep 1; kill -CONT $pid_script) &
;;
stop)
for p in $pid_script # kill all the other processes related with this script (if any)
do
kill -9 $p
done
esac