我有一个cron作业,在重启时加载Python脚本,但它不起作用。 我已经检查了Python脚本,这可以从CLi中正常工作。
.py基本上将浏览器加载到Google,然后将其发送到全屏。 (它实际上加载了另一个网站并输入了登录详细信息,但出于显而易见的原因被删除了)
现在已经好几个星期了,让我发疯了,有什么想法吗?
Raspberry Pi运行Raspbian。
$ crontab -e
@reboot DISPLAY =:0 python /prtgboot.py
prtgboot.py
'#'!/ usr / bin / env python
import commands
import time
webbrowser = "iceweasel"
pgrepcmd = "pgrep %s " % (webbrowser)
process = commands.getoutput(pgrepcmd)
if process == "":
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver import ActionChains
browser = webdriver.Firefox()
actions = ActionChains(browser)
browser.get('http://google.co.uk')
elemFullscreen = browser.find_element_by_tag_name('html')
time.sleep(30)
elemFullscreen.send_keys (Keys.F11)
exit()
else:
exit()
答案 0 :(得分:0)
好的,所以Petesh是对的。这是@reboot无法正常工作。
将cron更改为* * * * *,以便我的脚本每分钟运行一次。通常不好的做法,但是如果浏览器已经运行,已经设置脚本结束。现在就开始治疗吧。
从积极的方面来说,如果浏览器崩溃,它将再次为我启动:)