首页 > 编程语言 > 详细

Autorun a python script after reboot using rc.local

时间:2015-09-21 17:33:46      阅读:217      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!