Operations 6 min read
Master Linux Process Management and Scheduling: From ps to crontab
This guide explains Linux process concepts, how to view and trace processes with commands like ps and pstree, terminate them using kill, and schedule tasks both once with at and repeatedly with crontab, providing syntax, options, and practical examples.
Raymond Ops
Raymond Ops
Process Delay and Periodic Scheduling
Process Concept
<code>Process: an instance of a program that has started execution but not yet finished
Program: a file containing executable code
A process is created from a program and consumes system resources; it is not the same as the program.
Processes are classified as interactive, batch, or daemon.
The relationship between processes and programs is many‑to‑one.</code>Viewing Processes
<code>Command syntax: ps [options]
Options:
-A : display information for all processes (same as -e)
-a : display information for all user processes
-f : full format, showing all process details
-l : long format
-r : show only running processes
-u : user‑oriented format (includes user name, CPU and memory usage)
-x : display processes without a controlling terminal
-p : display information for the process with the given PID
-t : display processes attached to the specified terminal</code>Viewing Process Inheritance
<code>pstree command displays the inheritance relationship of system processes as a tree.
If a user is specified, only processes owned by that user are shown.
Syntax: pstree [options] [pid|user]
Options:
-a : show the complete inheritance chain; swapped‑out processes are shown in parentheses
-c : separate duplicate process names (default adds an asterisk *)
pid|user : specify the root process ID or user whose processes should be displayed</code>Process Termination
<code>kill [signal] pid
killall [signal] process_name
Use "ps -aux" to list processes.
Use "pstree" to view child processes.</code>Process Scheduling
Delay scheduling
<code>Function: schedule a program to run at a specified time.
Syntax: at [-f file] [-m] time
-f : specify a file containing commands to execute
-m : mail the user after the job finishes
Time formats:
Absolute: MMDDYY or MM/DD/YYYY, or keywords "today"/"tomorrow"
Relative: now+<number><unit> where unit can be minutes, hours, days, weeks
Examples:
at now+1 minutes # run in one minute
at -f file 17:30+2 days # run at 17:30 two days later</code>Periodic scheduling
<code>Function: plan recurring tasks.
Syntax: crontab –u user {-e | -l | -r}
-u : specify the user for which to manage tasks
-e : edit the task list
-l : list the task list (default is current user)
-r : remove the task list
Alternative: crontab –u user file # file contains the task definitions
Task file format: minute hour day month day-of-week command
Examples:
0 17 * * 1-5 # at 17:00 Monday‑Friday
30 8 * * 1,3,5 # at 08:30 on Mon, Wed, Fri
0 8-18/2 * * * # every 2 hours between 08:00 and 18:00
0 * */3 * * # every three days
Cron directory location: /var/spool/cron/root</code>Written by
Raymond Ops
Linux ops automation, cloud-native, Kubernetes, SRE, DevOps, Python, Golang and related tech discussions.
0 followers
Reader feedback
How this landed with the community
Rate this article
Was this worth your time?
Discussion
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.