0

I would like to open a web page in a browser on raspberry by running a python selenium script every n hours from the crontab.

Its a pretty standard script that works if I run it locally on that machine.

So if i connect a keyboard to the raspberry and run

python /home/pi/ww/open_dashboard.py >> /home/pi/ww/selenium_output.txt

it will open the browser and do the selenium commands that I need.

Now I can also ssh into the raspberry and run

export DISPLAY=:0 && python /home/pi/ww/open_dashboard.py >> /home/pi/ww/selenium_output.txt 

and I can see a browser open and do what I need on the monitor connected to the raspberry.

Now when I add this line to the cron.

57 9 * * * export DISPLAY=:0 && python /home/pi/ww/open_dashboard.py >> /home/pi/ww/selenium_output.txt

I can see that cron executed the command if I check grep CRON /var/log/syslog

Jul 18 09:57:01 raspberrypi CRON[2971]: (pi) CMD (export DISPLAY=:0 && python /home/pi/ww/open_dashboard.py >> /home/pi/ww/selenium_output.txt)

But browser did not open on the monitor connected to the raspberry. What could I be doing wrong here? :)

3
  • 1
    Crontab has no X11 session associated with it and so will not be able to work with GUIs and open browsers. Commented Jul 18, 2017 at 10:25
  • @holdenweb But I want it to access the physical display. I know how to run it headless, but I want it to actually display some dashboards for me. Commented Jul 19, 2017 at 10:14
  • The question in stackoverflow.com/questions/25027385/… is about selenium and this question is about cron and xvfb. I dont have any issues running selenium on raspberry. I have an issue with cron using the default display. Commented Jul 19, 2017 at 10:23

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.