Process Management
Managing processes is essential for running long bioinformatics analyses.
Step 1: View Running Processes
# Show your current processes psPID TTY TIME CMD 12345 pts/0 00:00:00 bash 12400 pts/0 00:00:00 ps# Show all processes (abbreviated output) ps aux | head -5USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.0 0.1 16894 1340 ? Ss Jan19 0:02 /sbin/init root 2 0.0 0.0 0 0 ? S Jan19 0:00 [kthreadd] ...# Interactive view (press 'q' to quit) top
Step 2: Run Commands in Background
# Start a long-running process (sleep simulates a long job) sleep 60 &[1] 12456# List background jobs jobs[1]+ Running sleep 60 &# Bring to foreground fg %1 # Press Ctrl+C to stop, or Ctrl+Z to suspend
Step 3: Kill Processes
# Start a background process sleep 300 &[1] 12500# Kill by job number kill %1 jobs[1]+ Terminated sleep 300# Or kill by PID sleep 300 & ps | grep sleep12510 pts/0 00:00:00 sleepkill 12510
Step 4: Keep Processes Running After Logout
# nohup keeps process running after you log out nohup sleep 120 > mysleep.log 2>&1 &[1] 12600# Check it's running jobs ps aux | grep sleep # You can now log out and the process continues!
Process Signals Reference
| Signal | Number | Shortcut | Description |
|---|---|---|---|
| SIGINT | 2 | Ctrl+C | Interrupt (stop) |
| SIGTSTP | 20 | Ctrl+Z | Suspend (pause) |
| SIGTERM | 15 | kill PID |
Terminate gracefully |
| SIGKILL | 9 | kill -9 PID |
Force kill |