1

i have recently bought a raspberry pi 4 module b to be able to run programs 24/7. but sometimes my power/electricity can go out at which then makes the program stop working.

i tested my program in the terminal by typing 'python3 /home/pi/Documents/folder/program.py' and it worked as i wanted it to. so then i looked for a way to run the program when booting up and found crontab

i wrote in the terminal 'sudo crontab -e' and wrote at the bottem of the crontab '@reboot sleep 15; python3 /home/pi/Documents/folder/program.py'. this failed so i tested a second and much simpeler program which didn't have any modules and it did work.(note the whole program does not work even if you don't use the module imported)

what is causing the modules to not work and what do i have to do to make the modules work?

1
  • You are (I assume) testing the script as user pi and creating an entry in root's crontab. Put the same line (@reboot ...) in pi's crontab: log in as pi and enter crontab -e (without sudo). Another common pitfall is that the environment and shell for a cron job may not be same as for an interactive session. Watch out for that. Commented Jan 5, 2022 at 17:12

0

Browse other questions tagged or ask your own question.