Nov 22, 2017

Suspend and resume process on Linux

Ctrl+z suspends the foreground process. bg resumes suspended process and sends it to the background.  By default fg brings first back ground running process to foreground.

$ jobs -l
~$ ping yahoo.ca
PING yahoo.ca (77.238.184.24) 56(84) bytes of data.
64 bytes from aviate.yahoo.com (77.238.184.24): icmp_seq=1 ttl=52 time=113 ms
64 bytes from aviate.yahoo.com (77.238.184.24): icmp_seq=2 ttl=52 time=112 ms
64 bytes from aviate.yahoo.com (77.238.184.24): icmp_seq=3 ttl=52 time=120 ms
64 bytes from aviate.yahoo.com (77.238.184.24): icmp_seq=4 ttl=52 time=111 ms
^Z
[1]+  Stopped                 ping yahoo.ca
~$ jobs -l
[1]+  6588 Stopped                 ping yahoo.ca
~$ bg
[1]+ ping yahoo.ca &
~$ 64 bytes from aviate.yahoo.com (77.238.184.24): icmp_seq=5 ttl=52 time=119 ms
64 bytes from aviate.yahoo.com (77.238.184.24): icmp_seq=6 ttl=52 time=137 ms
64 bytes from aviate.yahoo.com (77.238.184.24): icmp_seq=7 ttl=52 time=112 ms
f64 bytes from aviate.yahoo.com (77.238.184.24): icmp_seq=15 ttl=52 time=112 ms
g
ping yahoo.ca
64 bytes from aviate.yahoo.com (77.238.184.24): icmp_seq=16 ttl=52 time=113 ms
64 bytes from aviate.yahoo.com (77.238.184.24): icmp_seq=17 ttl=52 time=114 ms
64 bytes from aviate.yahoo.com (77.238.184.24): icmp_seq=18 ttl=52 time=113 ms
^Z
[1]+  Stopped                 ping yahoo.ca
~$ jobs -l
[1]+  6588 Stopped                 ping yahoo.ca