比如有一个文件:/home/abc/hello.py,开机后在命令行可以执行:sudo python /home/abc/hello.py,如果要开机自动运行,怎么办呢?
先谢谢各位。
python脚本怎么开机自动运行?
-
- 帖子: 33
- 注册时间: 2013-10-21 18:57
-
- 帖子: 33
- 注册时间: 2013-10-21 18:57
python脚本怎么开机自动运行?
比如有一个文件:/home/abc/hello.py,开机后在命令行可以执行:sudo python /home/abc/hello.py,如果要开机自动运行,怎么办呢?
先谢谢各位。
先谢谢各位。
- raptorsun
- 帖子: 25
- 注册时间: 2008-08-26 23:59
Re: python脚本怎么开机自动运行?
/etc/init 这个目录下面的脚本都会在启动时执行。 在下面写个脚本包含你想执行的命令就好啦 

-
- 论坛版主
- 帖子: 18279
- 注册时间: 2009-08-04 16:33
Re: python脚本怎么开机自动运行?
試試
在 /etc/rc.local
最後一行
exit 0
前面 加上
python /home/abc/hello.py
然後重開機
在 /etc/rc.local
最後一行
exit 0
前面 加上
python /home/abc/hello.py
然後重開機
-
- 帖子: 294
- 注册时间: 2007-06-02 20:00
-
- 帖子: 33
- 注册时间: 2013-10-21 18:57
Re: python脚本怎么开机自动运行?
谢谢楼上各位,按照所说方法做好了。