On my server, python scripts can be started either through a cronjob, or through our website (via apache). Sometimes I want to kill processes started by one, but not the other. When I run htop
, it looks like the user is “ubuntu” for both. Is there a way to determine natively which process started the script? Or if not natively, indicate how it was started?
Ideally I’d write another script in python that would find those processes (let’s say those started by apache) and kill them while leaving the cronjobs alone. Meaning I can leverage both linux and python tools for this purpose.
UPDATE: Thanks for all the comments, they’ve opened up some avenues for me to try (namely the Process ID group and using a different user for the cronjob). Will post an answer when I get it nailed down.
10