Crontab作业将无法在重新启动时运行Python脚本

时间:2016-12-28 20:38:16

标签: 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'

脚本失败。报告connection refused消息。

脚本导入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

0 个答案:

没有答案