3

I'm runing crontab with selenium and chromium.

If I don't run the script with crontab evertithing works fine.

I want to display the the screen on startup but it gives me this error.

(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /usr/bin/chromium-browser is no longer running, so 
 ChromeDriver is assuming that Chrome has crashed.)

This is my cron:

 @reboot DISPLAY=:0 sudo /usr/bin/python3 /home/pi/main.py > /home/pi/selenium.log 2>&1

My python code:

from selenium import webdriver

chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--no-sandbox')

driver = webdriver.Chrome( executable_path="/usr/bin/chromedriver" ,
    service_args= [ "--verbose", "--log-path=/tmp/CHROMIUM_LOG" ],
    options = chrome_options
)

I've tried evertithong from this post already.

Also if there is any other way to run the script on stratup and display the browser please let me know.

ikenas
  • 411
  • 3
  • 11

1 Answers1

0

I experimented a lot with this and the only way it worked for me was to set 2 minute timer to start the script.

I changed the crontab to this:

@reboot DISPLAY=:0 sleep 120 && sudo /usr/bin/python3 /home/pi/main.py > /home/pi/selenium.log 2>&1
ikenas
  • 411
  • 3
  • 11