Hoping someone can help…
I have been playing around with my scroll pHat HD. My plan was to run one of the python scripts at startup, so I could just turn on the pi and it would automatically start displaying text without any need for logging on.
To achieve this I used cron, added an extra line at the bottom of the file “@reboot python /home/pi/hello-world.py &”
It worked a treat but now I have to way to stop it displaying that message without turning the pi off and removing that line from the file.
Normally when running the python script from terminal you are given the option to press Ctrl + C and stop the script… unfortunately when booting at startup I do not seem to have this option.
I have tried finding the hello-world.py in task manger… but cannot seem to find it anywhere.
Any attempt to run new scripts just overlays them on top of “hello-world.py”.
Kind regards,
Alex
Hey there alexmburns,
You can terminate a Python script from the terminal by using the command “ps aux | grep -i [process name]
” without the square brackets and find the PID number (usually a long number on the second colum). You can then kill the process using “kill [PID]
”, again, without the square brackets.
This might explain things a little better. :)
Or the reckless, lazy way: “sudo killall python
”
Muwahahaha muwahahahahaha muwahahahahahahahahahah!
2 Likes
Thanks guys, I will give this a go tomorrow and let you know how it goes.
Sudo top, shows all the running processes, you should be able to see your script running in the list. CTL c to exit and use sudo kill plus the process number to stop it running.
Hope that helps
2 Likes
Perfect. Works an absolute treat. Thanks again.
1 Like
No problemo, though both Evil Gee (while sceptical) and CannonFodders answers will both achieve similar results and may be handy if you want to automate anything! :)