|$ curl https://forge-ai.dev/api/markdown?path=docs/linux/processes
$cat docs/processes-&-services.md
updated Recently·24 min read·published

Processes & Services

LinuxProcessessystemdServicesIntermediate🎯Free Tools
Introduction

Every running program on Linux is a process with a unique PID. Services are long-running processes managed by an init system. Understanding how to inspect, control, and schedule processes is critical for operations and debugging.

Inspecting Processes
inspecting.sh
Bash
1# Snapshot of processes
2ps aux
3ps aux | grep nginx
4
5# Process tree
6pstree
7
8# Real-time monitor
9top
10htop # interactive, requires installation
11
12# Find process by name
13pgrep nginx
14pidof nginx
15
16# Detailed info for a process
17cat /proc/1234/status
Signals

Signals are a form of inter-process communication. The kill command sends signals to processes.

SignalValueDefault Action
SIGHUP1Hang up / reload config
SIGINT2Interrupt (Ctrl+C)
SIGKILL9Force kill, cannot be caught
SIGTERM15Graceful termination
SIGSTOP19Pause (Ctrl+Z)
SIGCONT18Resume paused process
signals.sh
Bash
1kill -TERM 1234 # graceful stop
2kill -9 1234 # force kill
3pkill node # kill all processes named node
4killall firefox
systemd Services
systemd.sh
Bash
1# View service status
2sudo systemctl status nginx
3
4# Start, stop, restart, reload
5sudo systemctl start nginx
6sudo systemctl stop nginx
7sudo systemctl restart nginx
8sudo systemctl reload nginx # reload config without dropping connections
9
10# Enable / disable start on boot
11sudo systemctl enable nginx
12sudo systemctl disable nginx
13
14# List all active services
15systemctl list-units --type=service --state=running
16
17# View logs
18journalctl -u nginx
19journalctl -u nginx -f # follow
Background Jobs
jobs.sh
Bash
1# Run in background
2long-running-task &
3
4# Send running process to background
5Ctrl + Z
6bg
7
8# Bring to foreground
9fg %1
10
11# List jobs
12jobs -l
13
14# Run immune to hangups
15nohup node server.js &
16nohup node server.js > app.log 2>&1 &
17
18# Modern alternative: systemd user service or tmux/screen
Scheduling with cron
cron.sh
Bash
1# Edit user crontab
2crontab -e
3
4# List crontab
5crontab -l
6
7# Example entries
8# Run backup every day at 2 AM
90 2 * * * /home/alice/backup.sh
10
11# Run health check every 5 minutes
12*/5 * * * * /usr/local/bin/health-check.sh
13
14# Run on Mondays at 9 AM
150 9 * * 1 /opt/weekly-report.sh

info

Crontab format: minute hour day-of-month month day-of-week command. Use * for "every."