This question already has an answer here:

I am trying to run a python script at the startup of pi. Python file name is test.py. I am using raspberrypi-3 .

The command I have used :-

pi@raspberrypi:~$ sudo crontab -e

I have added the line within it :-

@reboot python /home/pi/Desktop/test.py & 

/home/pi/Desktop is the path of the python file.

I am rebooting the system using sudo reboot but script is not working automatically, where it is working manually.

marked as duplicate by goldilocks Jun 13 '16 at 11:10

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Have you checked all the related posts? People will get annoyed if this has already been answered. If you have checked related posts you will need to edit your post and include the script and explain what part doesn't work. – joan Jun 13 '16 at 7:57
  • See also: raspberrypi.stackexchange.com/q/40493/5538 – goldilocks Jun 13 '16 at 11:11

cron is best used to run things on a timed schedule, it sometimes doesn't behave as expected at boot time. To run things at boot time under Raspbian Jessie, your best bet is to use systemd by following this tutorial.

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