Crontab Job赢得';t在重新启动时运行Python脚本
从终端手动运行Crontab Job赢得';t在重新启动时运行Python脚本,python,python-3.x,selenium,cron,Python,Python 3.x,Selenium,Cron,从终端手动运行python脚本时,脚本将成功运行 使用crontab-e计划时,使用以下条目: @reboot export DISPLAY=:0 sudo/bin/sleep 60&&gnome terminal-e'sudo python3/path/to/script/script.py' 脚本失败了。报告连接被拒绝的消息 该脚本导入selenium,并依靠Firefoxwebdriver以类似于kiosk的显示方式浏览网站 任何帮助都将不胜感激 编辑:当我使用crontab计划脚本时,终
python
脚本时,脚本将成功运行
使用crontab-e
计划时,使用以下条目:
@reboot export DISPLAY=:0 sudo/bin/sleep 60&&gnome terminal-e'sudo python3/path/to/script/script.py'
脚本失败了。报告连接被拒绝的消息
该脚本导入selenium
,并依靠Firefox
webdriver以类似于kiosk的显示方式浏览网站
任何帮助都将不胜感激
编辑:当我使用crontab
计划脚本时,终端中会打印以下错误:
Traceback (most recent call last):
File "/home/pi/Desktop/photo_frames/becky/get_urls.py", line 19, in <module>
driver = webdriver.Firefox()
File "/usr/local/lib/python3.4/dist-
packages/selenium/webdriver/firefox/webdriver.py", line 150, in __init__keep_alive=True)
File "/usr/local/lib/python3.4/dist-
packages/selenium/webdriver/remote/webdriver.py", line 92, in __init__
self.start_session(desired_capabilities, browser_profile)
File "/usr/local/lib/python3.4/dist-
packages/selenium/webdriver/remote/webdriver.py", line 179, in start_session
response = self.execute(Command.NEW_SESSION, capabilities)
File "/usr/local/lib/python3.4/dist-
packages/selenium/webdriver/remote/webdriver.py", line 236, in execute
self.error_handler.check_response(response)
File "/usr/local/lib/python3.4/dist-
packages/selenium/webdriver/remote/errorhandler.py", line 192, in
check_response raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: connection refused
回溯(最近一次呼叫最后一次):
文件“/home/pi/Desktop/photo_frames/becky/get_url.py”,第19行,在
driver=webdriver.Firefox()
文件“/usr/local/lib/python3.4/dist-
packages/selenium/webdriver/firefox/webdriver.py”,第150行,在_init__keep_alive=True中)
文件“/usr/local/lib/python3.4/dist-
packages/selenium/webdriver/remote/webdriver.py”,第92行,在__
self.start\u会话(所需的\u功能、浏览器\u配置文件)
文件“/usr/local/lib/python3.4/dist-
包/selenium/webdriver/remote/webdriver.py”,第179行,在启动会话中
响应=self.execute(Command.NEW_会话,功能)
文件“/usr/local/lib/python3.4/dist-
packages/selenium/webdriver/remote/webdriver.py”,第236行,执行
self.error\u handler.check\u响应(响应)
文件“/usr/local/lib/python3.4/dist-
packages/selenium/webdriver/remote/errorhandler.py”,第192行,在
检查\u响应引发异常\u类(消息、屏幕、堆栈跟踪)
selenium.common.exceptions.WebDriverException:消息:连接被拒绝
从终端成功运行的确切命令是什么?您是否尝试过从终端运行gnome terminal-e'sudo python3/path/to/script/script.py'
?它打开了gnome terminal
的一个新实例,并执行python
脚本。启动后60秒的睡眠是否足够长?也许python脚本需要的某些服务尚未启动?值得一试-我将尝试更长时间的睡眠并报告。从终端成功运行的确切命令是什么?您是否尝试过从终端运行gnome terminal-e'sudo python3/path/to/script/script.py'
,它打开一个新的gnome终端实例
,并执行python
脚本。启动后60秒的睡眠时间足够长吗?也许python脚本需要的某些服务还没有启动?值得一试——我将尝试更长时间的睡眠,并向您报告。