I bought a raspberry and I defined it to run a auto program in the boot by changing the rc.local. The problem is that the program is running and ctr+c doesn't work. There is a way to stop the program during it is running? There is a way to edit rc.local and fix it?
2 Answers
You can, of course, edit rc.local to remove that entry again. However that is not going to stop the running instance of that program, it just prevents that it is started again after the next reboot.
To stop that program do the following:
Run ps aux | grep <your-program's-name-here> (the listed example used ps aux | grep mopidy). You'll get a result like this
pi 280 0.0 19.4 218896 146148 ? Sl Apr09 0:54 /usr/bin/python2 /usr/bin/mopidy
pi 10052 0.0 0.0 2644 500 pts/0 S+ 21:26 0:00 grep mopidy
The number after pi (which is the user running the program) is the so called PID - a unique number identifying the running program. Use that number to issue this command to stop it from running: kill -TERM <PID> or if it still resists kill -KILL <PID>. In the example above that translates to kill -TERM 280 (see man kill).
If installed you might also want to use killall which kills processes by name (see man killall).
- 15,958
- 17
- 65
- 125
I highly recommend this as a guide to creating an automatically running daemon which you can start and stop from the commandline:
It's a simple matter of cutting and pasting the script and 3 tiny modifications.
- 718
- 1
- 9
- 24