October 2018
Beginner to intermediate
736 pages
17h 39m
English
Although the current trend for managing service processes in Linux systems is, as noted, moving toward systemd/systemctl, there may be operational systems that still use System V-style initialization scripts. A bare-bones starting point for such a script would look something like the following:
#!/bin/sh
# - The action we're concerned with appears as $1 in a standard
# bash-script
case $1 in
start)
echo "Starting $0"
/usr/bin/python /usr/local/bin/testdaemon.py
;;
stop)
echo "Stopping $0"
/usr/bin/pkill -f testdaemon.py
;;
restart)
echo "Restarting $0"
/usr/bin/pkill -f testdaemon.py
/usr/bin/python /usr/local/bin/testdaemon.py
;;
esac
In a System V-managed context, the service itself has to take responsibility ...