Skip to content

Instantly share code, notes, and snippets.

@VarunAgw
Created June 4, 2015 10:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save VarunAgw/9f116276a45939f37769 to your computer and use it in GitHub Desktop.
Save VarunAgw/9f116276a45939f37769 to your computer and use it in GitHub Desktop.
Process in background
Move running process in background
A) Ctrl + Z (It suspends (like pause) process)
B) bg (Its keeps running in background)
Move new process in background
A) sleep 10 & (Print output to terminal whenever it comes)
A) nohup sleep 10 & (Saves output to a file nohup.out)
A) sleep 10> /dev/null & (output is lost)
Move background process to foreground
B) fg (Bring it to foreground)
C) fg %1; fg %2 (with job id)
Get processes
A) ps (Show foreground/background processes)
A) jobs (Show background processes with status)
A) jobs -l (Show PID too)
Kill
A) kill %pid%
B) kill -9 %pid% (If A don't work)
Misc
A) !! (Repeat last command)
B) echo $! (Echo last PID (not works for service))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment