Below is a very simple python daemon script, which will print "Hello World!".
Make sure you install python-daemon in your linux machine.
sudo apt-get install python-daemon
Here’s the script.
#!/usr/bin/env python
import time
import subprocess
from daemon import runner
class Remote():
def __init__(self):
self.stdin_path = '/dev/null'
self.stdout_path = '/dev/tty'
self.stderr_path = '/dev/tty'
self.pidfile_path = '/tmp/remote.pid'
self.pidfile_timeout = 5
def run(self):
while True:
print "Hello World!"
time.sleep(15)
Remote = Remote()
daemon_runner = runner.DaemonRunner(Remote)
daemon_runner.do_action()