First thing to do is to record any errors to help work out why it's not working.
e.g.:
Code: Select all
@reboot python filepath 2>> /home/pi/reboot.log
Have a look at the cron and boot pdfs at
https://github.com/thagrol/Guides - specifically the troubleshooting sections and use of the redirect options in Linux.
It is also handy to read up on redirecting STDOUT and STDERR to file - Digital Ocean has a guide
here but this one of many.
Please understand that by running the job under the root cron (you used sudo to edit) the path and security for this command will be different to your standard user - some programs will be 'missing' as they are not on the path and everything is open - not good for security. The root user (and sudo / su) should only be used when there is NO OTHER WAY to achieve your needs and then only with extreme care.
edit: Forgot to add example redirect and note on sudo ...
