Skip to content

Instantly share code, notes, and snippets.

@pamolloy
Created September 25, 2018 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pamolloy/f72ca82f413719464260072eb46c5828 to your computer and use it in GitHub Desktop.
Save pamolloy/f72ca82f413719464260072eb46c5828 to your computer and use it in GitHub Desktop.
# start-stop-daemon -K -n "/root/foo"
no /root/foo found; none killed
# /root/grep-cmdline.bash
/root/foo
# ps aux | grep foo
1534 root bash /root/foo
2864 root grep foo
#!/usr/bin/env bash
for cl in /proc/*/cmdline; do
cat $cl | grep foo
done
#! /bin/sh
NAME=foo
DAEMON=/root/$NAME
case "$1" in
start)
printf "Starting $NAME: "
start-stop-daemon -S -q -b -x $DAEMON
[ $? = 0 ] && echo "OK" || echo "FAIL"
;;
stop)
set -x
printf "Stopping $NAME: "
start-stop-daemon -K -q -n $NAME
[ $? = 0 ] && echo "OK" || echo "FAIL"
set +x
;;
restart|reload)
echo "Restarting $NAME: "
$0 stop
sleep 1
$0 start
;;
*)
echo "Usage: $0 {start|stop|restart|reload}" >&2
exit 1
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment