# Launch Python script from Cron in foreground

I have developed a Python script that I would like to run at every boot of the Pi. The script in question is one that I do not want to run in the background. It will be controlling the display of webpages in a kiosk-like slideshow.

So far I have included the below in the crontab file edited via sudo:

@reboot \usr\bin\python3 \home\pi\Desktop\photo_frames\get_random_row.py > /logs/cronlog

Not only does this not run in the foreground, the logs indicate a Selenium error despite my ability to explicitly/manually run the Python script from terminal without issue.

Any help/explanation would be greatly appreciated.

To run in foreground you'd need to add DISPLAY=:0:
@reboot DISPLAY=:0 \usr\bin\python3 \home\pi\Desktop\photo_frames\get_random_row.py > /logs/cronlog

Or open it explicitly with xterm:
@reboot DISPLAY=:0 xterm -e \usr\bin\python3 \home\pi\Desktop\photo_frames\get_random_row.py /logs/cronlog