I have the following simple python script test.py
(toy example)
#!/usr/bin/python
import time
from time import gmtime, strftime
from daemon import runner
import config
import subprocess
class App():
def __init__(self):
self.stdin_path = '/dev/null'
self.stdout_path = '/dev/tty'
self.stderr_path = '/dev/tty'
self.pidfile_path = '/tmp/foo.pid'
self.pidfile_timeout = 5
def run(self):
while True:
file = open('/var/www/myfile.dat'+strftime("%Y-%m-%d %H:%M:%S", gmtime()), 'w+')
file.write("Hello World")
file.close()
time.sleep(20)
app = App()
daemon_runner = runner.DaemonRunner(app)
daemon_runner.do_action()
I want to run that script on the boot of Linux Centos 7.
For that reason I have added the line in rc.local
file
touch python /root/scripts/test.py start
but unfortunately the script doesn't run.
P.S. When I run that script from command line python test.py start
it works perfectly.