A cron-started process spawns children that keep running after the parent is killed. How do you clean this up properly?
AdvancedScenarioProcesses, services and systemd
Answer
Situation read → Orphaned process trees; you need group or cgroup-wide termination.
What I'd do →
- Now: find the process group/session and kill it:
ps -eo pid,pgid,sid,cmd | grep job
kill -TERM -- -<PGID>
- Long term: run the job as a systemd service/timer, so
systemctl stopkills the whole cgroup (KillMode=control-group, default).
Why → Signals sent to one PID don't reach its children; cgroups contain every descendant.
Interview tip → The minus sign in kill -- -PGID targets the process group, a detail interviewers like.
More on Processes, services and systemd
Your team has a Python API that someone starts with `nohup python app.py &`. Make it a proper service running as a non-root user.BeginnerThe service you created must bind to port 443, but it runs as a non-root user. How?BeginnerYou need to change one setting (memory limit) in a vendor-supplied unit file without editing it. How?BeginnerA service depends on a database on the same host and fails at boot because the DB isn't ready. How do you fix the ordering?IntermediateA service keeps crashing and systemd stops restarting it after a few attempts. How do you tune this?IntermediateA long-running app must reload its config without dropping connections. How do you wire this into systemd?Intermediate