nohup 程序名 & (使程序推到后台运行,即使终端关闭,该程序依然运行)
2024-10-12 23:06:37
IshallbeThatIshallbe:~ iamthat$ ps -ef |grep ping
502 450 1 0 9:30PM ?? 0:00.05 ping www.baidu.com
502 492 475 0 9:32PM ttys000 0:00.00 grep ping
IshallbeThatIshallbe:~ iamthat$ kill -9 502
-bash: kill: (502) - No such process
IshallbeThatIshallbe:~ iamthat$ kill -9 450
IshallbeThatIshallbe:~ iamthat$ ps -ef |grep ping
502 495 475 0 9:33PM ttys000 0:00.00 grep ping 首先我这里 kill ping 百度的进程 重新演示
创建程序: IshallbeThatIshallbe:~ iamthat$ nohup ping www.baidu.com >> ping.txt &
[1] 507 ---注意这为进程号
IshallbeThatIshallbe:~ iamthat$
可以看到该程序不断有输出 IshallbeThatIshallbe:~ iamthat$ tail -f ping.txt
64 bytes from 180.97.33.108: icmp_seq=19 ttl=54 time=46.477 ms
64 bytes from 180.97.33.108: icmp_seq=20 ttl=54 time=45.426 ms
64 bytes from 180.97.33.108: icmp_seq=21 ttl=54 time=46.482 ms
64 bytes from 180.97.33.108: icmp_seq=22 ttl=54 time=45.679 ms
64 bytes from 180.97.33.108: icmp_seq=23 ttl=54 time=46.772 ms
64 bytes from 180.97.33.108: icmp_seq=24 ttl=54 time=47.559 ms
64 bytes from 180.97.33.108: icmp_seq=25 ttl=54 time=45.568 ms
64 bytes from 180.97.33.108: icmp_seq=26 ttl=54 time=44.652 ms
64 bytes from 180.97.33.108: icmp_seq=27 ttl=54 time=44.747 ms
64 bytes from 180.97.33.108: icmp_seq=28 ttl=54 time=45.868 ms
64 bytes from 180.97.33.108: icmp_seq=29 ttl=54 time=47.068 ms
64 bytes from 180.97.33.108: icmp_seq=30 ttl=54 time=46.171 ms
64 bytes from 180.97.33.108: icmp_seq=31 ttl=54 time=47.026 ms
64 bytes from 180.97.33.108: icmp_seq=32 ttl=54 time=45.162 ms
64
关闭终端,重新打开一个终端
Last login: Wed Apr 1 21:37:38 on ttys000
IshallbeThatIshallbe:~ iamthat$ tail -f ping.txt
64 bytes from 180.97.33.108: icmp_seq=76 ttl=54 time=48.586 ms
64 bytes from 180.97.33.108: icmp_seq=77 ttl=54 time=46.160 ms
64 bytes from 180.97.33.108: icmp_seq=78 ttl=54 time=48.099 ms
64 bytes from 180.97.33.108: icmp_seq=79 ttl=54 time=44.345 ms
64 bytes from 180.97.33.108: icmp_seq=80 ttl=54 time=47.058 ms
64 bytes from 180.97.33.108: icmp_seq=81 ttl=54 time=44.917 ms
64 bytes from 180.97.33.108: icmp_seq=82 ttl=54 time=44.886 ms
64 bytes from 180.97.33.108: icmp_seq=83 ttl=54 time=47.997 ms
64 bytes from 180.97.33.108: icmp_seq=84 ttl=54 time=45.928 ms
64 bytes from 180.97.33.108: icmp_seq=85 ttl=54 time=46.988 ms
64 bytes from 180.97.33.108: icmp_seq=86 ttl=54 time=44.337 ms
64 bytes from 180.97.33.108: icmp_seq=87 ttl=54 time=48.580 ms
程序依然在输出在运行。
可以看到那个507的进程一直在跑 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 0:00.00 grep ping
IshallbeThatIshallbe:~ iamthat$
最新文章
- maven 下载 源码和javadoc 命令
- [Tools] 使用work2013发布博客
- 关于jsonp跨域过程中 cookie中的值一直为null的原因
- java连接mongodb的一个奇葩问题及奇葩解决方式
- PHP变量作用域以及地址引用问题
- CSS(04) 定位
- hdu 4696 Answers
- iOS之应用内跳转系统设置相关界面
- Qt编程之信号与槽-------unresolved external symbol ";public: virtual struct QMetaObject const * __thiscall XX::metaObject(void)const
- 启动网页时候自己主动载入servlet假设不使用strus最经常使用的两种方式
- mov sreg, r/m16 在16位和32位编程中的区别
- typeof判断类型(数组类型得用instanceof)
- 如何使用DockerHub官方的mysql镜像
- PHP小技巧
- pyc
- 开机出现loading (hd0)/ntldr。。。
- squid 透明代理配置
- JDK命令行工具
- NoSQL&;Redis
- learning at commad AT+CPSI