impactoz
Full Member
Posts: 142
Raspberry Pi: Yes
|
Post by impactoz on Sept 4, 2019 0:21:33 GMT -8
/home/pi/SDL_Pi_SkyWeather/
echo $! > /home/pi/SDL_Pi_SkyWeather/SkyWeather.pid
Each time the machine boots, it will save the process id of Skyweather in this file - saves doing a 'ps -ax | grep python' in a terminal window to try and find it....
But you can create a script now in SDL_Pi_SkyWeather folder called StopSW.sh with the contents;
#!/bin/bash
echo "Stopping SkyWeather..."
kill -9 `cat /home/pi/SDL_Pi_SkyWeather/SkyWeather.pid`
echo "SkyWeather is now stopped."
Then executing this script will kill the background task running SkyWeather...
You can then modify any code you want, test out new ideas... play, and break the code... Run the SkyWeather app in the foreground, stop and start it with just a ctrl-C Then next time you reboot the machine SkyWeather will commence as a background task automatically again...
|
|
|
Post by doxidad on Sept 4, 2019 4:22:33 GMT -8
Nice ^^
To add to handy things - here's something that has followed me around for the past 30+ years.
Here's a little command I called psg (ps and grep).
#!/bin/bash ps ax | grep $1 | grep -v grep | grep -v psg
Create these 2 lines in a file called psg in your bin directory (~pi/bin) - if bin doesn't exist created it with mkdir bin then change the the protection on the file psg to be executable chmod 755 psg
Since your bin directory is in your path you should be able to just type psg python at the prompt to find if python is running or any other program that you would like (or string).
What the script does is executes the ps command and searches for the string you entered (that's the $1) and then removes anything from the output with the string grep and then the same with the string psg so you only get what you are searching for not the commands that you are using to do the search.
Hopefully somebody will find this useful.
|
|