У меня есть простая программа, которая использует хромовый драйвер селена, открывает страницу и закрывает ее.
Запуск из командной строки работает хорошо, а также помещает объект в файл .sh и запускает sh.
Но при выполнении задания CRON я получаю ошибку ниже:
Traceback (most recent call last):
File "/home/lmsanch/Documents/dsx/test.py", line 34, in <module>
driver = webdriver.Chrome(executable_path='/usr/bin/chromedriver', options=options)
File "/home/lmsanch/anaconda3/lib/python3.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 81, in __init__
desired_capabilities=desired_capabilities)
File "/home/lmsanch/anaconda3/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
self.start_session(capabilities, browser_profile)
File "/home/lmsanch/anaconda3/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/home/lmsanch/anaconda3/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "/home/lmsanch/anaconda3/lib/python3.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally
(chrome not reachable)
(The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
Если я делаю
echo $ SHELL
Я получаю:
/bin/bash
для эха $ PATH
Я получаю:
/home/lmsanch/anaconda3/bin:/home/lmsanch/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/lmsanch/bin
за $, где хромродрайвер, я получаю
хромированный драйвер: / usr / bin / chromedriver
Я добавляю эту ОБОЛОЧКУ и ПУТЬ к моему КРОНУ:
SHELL=/bin/bash
PATH=/home/lmsanch/anaconda3/bin:/home/lmsanch/bin:/usr/local/sbin:/usr/local/b$
* * * * * /home/lmsanch/Documents/dsx/test.py > /tmp/test.log 2>&1
Эта работа вызывает ошибку, указанную выше. Я не совсем уверен, что здесь происходит (я новичок в работе с CRON и chormedriver).
my test.py - это исполняемый файл (chmod + x test.py), который начинается с пути к моему питону anaconda #!/home/lmsanch/anaconda3/bin/python
, начиная с $which python
Есть подсказки? Спасибо.