I run into a question that I want to auto run a server in python when boot the Raspberry Pi every time. I tried several methods but they all don't work for me. Assume my python file is
/home/pi/Desktop/server.py
I tried to use crontab and wrote
@reboot python /home/pi/Desktop/server.py &
But it doesn't work. I check the the server doesn't start. I also tried to wrote in /etc/rc.local
python /home/pi/Desktop/server.py &
Still doesn't work.
Only wrritten in
/home/pi/.bashrc
works now. But it needs me to use ssh to remote login in and then start run the server. What I want is just the server would auto run after I reboot the Pi, not needing to login in. Anyway has ideas?
#!/usr/bin/python3
?/ usr/bin/python
. Cron is known to be peculiar about that. Note also that there is no need for an ampersand in crontabs (though that should not make it fail either).