码迷,mamicode.com
首页 > 编程语言 > 详细

Autorun a python script after reboot using rc.local

时间:2015-09-21 17:37:04      阅读:150      评论:0      收藏:0      [点我收藏+]

标签:

1. /home/lvtest/test/test.py  

from datetime import datetime
now=datetime.now()
f=open(test.log,a)
f.write(%s %now)
f.close()

2. edit /etc/rc.local with adding codes below:

  cd /home/lvtest/test

  su lvtest -c "python /home/lvtest/test/test.py"

  exit 0  # ? if it is necessary

3. Make your /etc/rc.local executable in case it is not already executable by

  sudo chown root /etc/rc.local

  sudo chmod 755 /etc/rc.local

4. Check everything works fine by executing

  sudo /etc/rc.local start

Autorun a python script after reboot using rc.local

标签:

原文地址:http://www.cnblogs.com/irun/p/4826289.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!