0

我有一个 cron 作业,它在重新启动时加载 Python 脚本,但它不会工作。我已经检查了 Python 脚本,并且在 CLi 中运行良好。

.py 基本上将浏览器加载到 Google,然后将其发送到全屏。(它实际上加载了另一个网站并输入了登录详细信息,但由于明显的原因被删除了)

几个星期以来一直在这让我发疯,有什么想法吗?

运行 Raspbian 的树莓派。

  • $crontab -e

    @reboot 显示=: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()
4

1 回答 1

0

好的,所以Petesh是正确的。这是@reboot 无法正常工作。

将 cron 更改为 * * * * * 以便我的脚本每分钟运行一次。通常是不好的做法,但如果浏览器已经运行,则已经设置脚本结束。现在工作请客。

积极的一面是,如果浏览器崩溃,它会为我重新启动:)

于 2015-09-29T09:37:13.610 回答