The sample code for today is how to make an init script to run your program as a detached daemon using screen. The cool thing about this is it lets you connect to it at any time to see what it is doing. This is not recommend for normal use but it is a great way to debug that new program before you commit to making it a proper daemon.
#!/bin/bash cd /etc/init.d start() { echo "Starting Service: " APP_CMD="/usr/local/bin/MyProgram.pl" screen -dmS pmsgd $APP_CMD echo } stop() { echo "Cannot stop screen programs this way. Open the screen sessions." echo } restart() { stop start } # See how we were called. case "$1" in start) start ;; stop) stop ;; restart) restart ;; *) printf "Usage: %s {start|stop|restart}\n" "$0" exit 1 esac exit 0