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? :)

raitisd
  • 3,875
  • 5
  • 26
  • 37
  • 1
    Crontab has no X11 session associated with it and so will not be able to work with GUIs and open browsers. – Raman Sailopal Jul 18 '17 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. – raitisd Jul 19 '17 at 10:14
  • The question in https://stackoverflow.com/questions/25027385/using-selenium-on-raspberry-pi-headless 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. – raitisd Jul 19 '17 at 10:23

0 Answers0