Hi scripting experts!
I have been running a command for sometime that logs info on new aircraft I have not spotted before, it is basically reading port 30003 and dumping it to a text file through some egrep/grep filters.
Recently I scripted it up to try and get it to run daily instead of just leaving it running till I next checked as the output files were getting rather large.
Here is the script (feeder.sh)
wget -O - -q http://172.16.30.202:30003 | egrep --line-buffered ‘MSG,6’ | grep -Ev -f known.txt >> /home/pi/logs/$NOW.txt
The known.txt file is the list of ICAO hex codes I have seen (I update this manually), format is 00A2E4|00B290|00FCE8|06A066 etc…
If I run the script from a command prompt, it runs fine. If I schedule it to run from crontab (05 07 * * * /home/pi/feeder.sh) it is also fine
Now the issue I am having is how to kill the process everyday. I tried “00 07 * * * kill $(pgrep feeder.sh >/dev/null 2>&1)” to kill the process but it keeps running.
I suspect I need to target the wget commands instead. I am no expert on crontab and are only using the pi user one not root.
I also don’t fully understand the purpose of >/dev/null 2>&1 at the end of the crontab commands. When I ran my script with that it would start and immediately terminate, so I removed the >/dev/null 2>&1 statement and this issue went away, if I remove that from the terminate statement it kills the whole pi!