一、使用两种方法在后台运行 ping 127.0.0.1,并把 STDOUT 输出到 /tmp/stdout,把 STDERR 输出到 /tmp/stderr
# 用户退出服务器后程序就停止了
ping 127.0.0.1 >> /tmp/stdout 2> /tmp/stderr &
# nuhop 就是不挂起的意思,这样当你用户退出服务器后,程序还会运行
nohup ping 127.0.0.1 >> tmp/stdout 2> /tmp/stderr &
# 打开文件查看
PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.049 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.054 ms
64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.054 ms
64 bytes from 127.0.0.1: icmp_seq=4 ttl=64 time=0.054 ms
64 bytes from 127.0.0.1: icmp_seq=5 ttl=64 time=0.055 ms