我有一个需要在启动时运行的简短Python脚本--Ubuntu 13.10.我已经尝试了所有我能想到但却无法运行的东西.剧本:
#!/usr/bin/python
import time
with open("/home/username/Desktop/startup.txt", 'a') as f:
f.write(str(time.time()) + " It worked!")
Run Code Online (Sandbox Code Playgroud)
(实际的脚本有点不同,因为我只是将它用于测试目的,但你明白了.)
我已经尝试了以下所有方面,没有运气:
把命令python startuptest.py中crontab,因为@reboot
python /home/username/Documents/startuptest.py,无论是作为普通用户和sudo
把命令python /home/username/Documents/startuptest.py放入/etc/rc.local
打开Ubuntu的启动应用程序并将命令放在那里
完成上述所有操作,将命令放入shell脚本并调用该shell脚本
什么都行不通.我觉得我错过了一些简单的事情.有任何想法吗?(如果我只是从终端运行命令,脚本运行正常.)