Investigate a resource-heavy process, control it using job management, and terminate it safely when needed. Then schedule follow-up actions using one-time and recurring schedulers.
A developer reports that the dev server keeps “freezing” during their data run. You suspect a runaway job is consuming memory, and you need to identify it, control it, and prevent similar issues by scheduling monitoring and cleanup tasks.
This is the workflow you use when you need evidence first, then controlled intervention: observe, isolate, stop, then automate guardrails.
at.
ps.
&,
jobs, fg, Ctrl+Z.
kill (SIGTERM).
at.
crontab.
ps -eo pid,user,%mem,comm --sort=-%mem
This gives you an evidence-first view of resource usage so you can identify the likely offender before you touch anything.
PID USER %MEM COMMAND
2387 alice 13.2 code
2194 alice 9.8 firefox
2381 dev 6.9 python3
python3 data_job.py &
Appending & starts the job in the background
and returns control of the shell immediately.
[1] 2381
jobs
jobs shows processes managed by your current
shell session (not system-wide processes).
[1]+ Running python3 data_job.py &
fg %1
Foregrounding the job allows interactive control. In a real
session, you suspend it with Ctrl+Z to stop it
without killing it.
python3 data_job.py
[1]+ Stopped python3 data_job.py
kill %1
Default kill sends SIGTERM, which is the
“polite” termination signal. If a process ignores it, that
is when you consider escalation, but SIGTERM is the correct
first move in most admin workflows.
# No output on success
echo '/usr/local/bin/cleanup.sh' | at now + 2 minutes
at is for one-off scheduling. This is useful
for deferred cleanup, delayed restarts, or running a script
once after a short buffer.
job 4 at Sat Jul 20 21:59:00 2025
monitor.sh every day at midnight.
(crontab -l; echo '0 0 * * * /usr/local/bin/monitor.sh') | crontab -
This preserves existing entries, then appends the new daily schedule. Midnight daily is a common baseline for checks, reports, and housekeeping tasks.
# crontab installs silently on success
ps -eo ... --sort=-%mem: Lists processes with selected fields, sorted by memory usage.
jobs: Lists background/managed jobs in the current shell session.
fg %N: Brings job %N to the foreground.
Ctrl+Z: Suspends the current foreground job (stops it).
kill %N: Sends a signal to job %N (default SIGTERM).
at now + 2 minutes: Schedules a one-time job to run in two minutes.
crontab -l / crontab -: Reads current cron entries and installs a new crontab.