2

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.

count zero
  • 43
  • 6
  • [Here is another option](https://stackoverflow.com/a/66035900/6340496) to consider. Using a system service, rather than crontab, as this will ensure the appropriate supporting services are already running. – S3DEV Feb 13 '21 at 21:43

1 Answers1

0

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.

William Mou
  • 301
  • 2
  • 4
  • 1
    hi william,thank you for responding but it did not work, the raspberry pi boots up normally, I tried with more time and nothing. Is there another way? – count zero Feb 13 '21 at 18:17
  • the display I am using is connected by the GPIO pins, its a touch screen, I dont know if that changes anything. – count zero Feb 13 '21 at 18:32