1. First is add a SHEBANG line on top of your python script
#!/usr/bin/env python
2. Make your script executable with
chmod a+x
3. Open crontab with
sudo crontab -e
4. Add the following line. Make sure to include the full path to the script (MyScript.py is the name of your script)
@reboot python /home/pi/Desktop/MyScript.py &
5. To save these changes click “CTRL-X”, then “Y” and finally “Return”. You should now be back at the command prompt.
To start testing you can now reboot