ishallbethatishallbe:~ iamthat$ ps-ef |grep Ping 502 1 0 9:30PM?? 0:00.05 Ping www.baidu.com 502 492 475 0 9:32pm ttys000 0:00.00 grep pingishallbethatishallbe:~ iamthat$ kill-9 502-bash:kill: (502)-No such processishallbethatishallbe:~ iamthat$ kill-9 450ishallbethatishallbe:~ iamthat$ ps-ef |grep Ping 502 495 475 0 9:33pm ttys000 0:00.00 grep Ping First I here kill ping Baidu process re-demo
Create program: ishallbethatishallbe:~ iamthat$ nohup ping www.baidu.com >> ping.txt &[1] 507
Close the terminal and reopen a terminal
Last login:wed Apr 1 21:37:38 in ttys000ishallbethatishallbe:~ iamthat$ tail-f ping.txt 33.108 bytes from 180.97. icmp_seq=76 ttl=54 time=48.586 ms64 bytes from 180.97.33.108:icmp_seq=77 ttl=54 time=46.160 ms64 bytes from 180.97.33.10 8:icmp_seq=78 ttl=54 time=48.099 ms64 bytes from 180.97.33.108:icmp_seq=79 ttl=54 time=44.345 ms64 bytes from 180.97.33. 108:icmp_seq=80 ttl=54 time=47.058 ms64 bytes from 180.97.33.108:icmp_seq=81 ttl=54 time=44.917 ms64 bytes from 180.97.3 3.108:icmp_seq=82 ttl=54 time=44.886 ms64 bytes from 180.97.33.108:icmp_seq=83 ttl=54 time=47.997 ms64 bytes from 180.97 .33.108:icmp_seq=84 ttl=54 time=45.928 ms64 bytes from 180.97.33.108:icmp_seq=85 ttl=54 time=46.988 ms64 bytes from 180. 97.33.108:icmp_seq=86 ttl=54 time=44.337 ms64 bytes from 180.97.33.108:icmp_seq=87 ttl=54 time=48.580 ms
The program is still running in the output.
Can see that 507 of the process has been running ishallbethatishallbe:~ iamthat$ ps-ef |grep Ping 502 507 1 0 9:36pm?? 0:00.05 Ping www.baidu.com 502 528 520 0 9:38pm ttys000
Nohup Program Name & (causes the program to run in the background, even if the terminal is closed, the program is still running)