Is it possible to tag a python program run from the command line?
Context: Said command will be run with nohup
in the background, and will be killed and restarted at midnight via cron
. My intention is to pipe ps
into egrep
for said tag, grab the pid
, and kill -9
before restarting.
minimal, complete, and verifiable example
Start a python web server:
$ nohup python -m http.server 8888 &
Add a tag to the command. Note that -tag
is just my imagination at work.. this is what I want:
$ nohup python -m http.server 8888 & -tag "ced72ca0-cd19-11ea-87d0-0242ac130003"
grep
for tag:
$ ps aux | egrep "ced72ca0-cd19-11ea-87d0-0242ac130003"
...grab the pid from this, and kill -9