2

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.

4

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

Generally if it's Python, you could use logging library instead of stdout and redirection.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.