crontab doesnt run python script on a raspberry pi 4

Viewed 891

I'm trying to run a python script automatically when the raspberry pi 4 turns on, and I'm using crontab to do it. The script is a GUI that helps fill and search a database. the raspberry pi doesnt give any errors or exceptions, it just turns on normally and gives no signal of running the script. the command I used in crontab is:

@reboot python3 /home/pi/Desktop/folder/gui.py &

the libraries that the script uses are:

  • tkinter
  • subprocess
  • pyserial
  • csv

thank you for your time, this is my first time working in the raspberry pi or a linux environment so I dont understand many things about it.

1 Answers

On the Raspberry Pi, the service that your program needs to use may not be activated. In your example, the Display service may not be activated.

Try to do the following:

@reboot sleep 60 && python3 /home/pi/Desktop/folder/gui.py &

Wait 60s (or more) after the Raspberry Pi starts, which may prevent the code from failing and help solve your problem.

Related