如何使程序后台不中断运行,关闭当前shell也不会中断
答案:2 mip版
解决时间 2021-01-16 04:17
- 提问者网友: 妳莂騙莪
- 2021-01-15 23:22
如何使程序后台不中断运行,关闭当前shell也不会中断
最佳答案
- 二级知识专家网友:归人
- 2021-01-15 23:31
[root@localhost ~]# screen -S a
[root@localhost ~]# sleep 10000
然后ctrl+a+d
这样就保存了screen,在里面执行的sleep还在执行
[root@localhost ~]# ps aux|grep sleep
root 8817 0.0 0.1 100904 564 ? S 15:47 0:00 sleep 60
root 8854 0.0 0.1 100904 564 pts/2 S+ 15:48 0:00 sleep 10000
root 8856 0.0 0.1 103176 844 pts/1 S+ 15:48 0:00 grep sleep
查看下当前有哪些screen:
[root@localhost ~]# screen -ls
There is a screen on:
8844.a (Detached)
1 Socket in /var/run/screen/S-root.
进去你想进的screen:
[root@localhost ~]# screen -r 8844
或者
[root@localhost ~]# screen -r a
或者(当前只有1个screen)
[root@localhost ~]# screen -r
你又可以看到sleep还在那跑了,退出screen按ctrl+d
[root@localhost ~]# sleep 10000
然后ctrl+a+d
这样就保存了screen,在里面执行的sleep还在执行
[root@localhost ~]# ps aux|grep sleep
root 8817 0.0 0.1 100904 564 ? S 15:47 0:00 sleep 60
root 8854 0.0 0.1 100904 564 pts/2 S+ 15:48 0:00 sleep 10000
root 8856 0.0 0.1 103176 844 pts/1 S+ 15:48 0:00 grep sleep
查看下当前有哪些screen:
[root@localhost ~]# screen -ls
There is a screen on:
8844.a (Detached)
1 Socket in /var/run/screen/S-root.
进去你想进的screen:
[root@localhost ~]# screen -r 8844
或者
[root@localhost ~]# screen -r a
或者(当前只有1个screen)
[root@localhost ~]# screen -r
你又可以看到sleep还在那跑了,退出screen按ctrl+d
全部回答
- 1楼网友:没仙气的仙女
- 2021-01-16 01:10
你好!
建议你学习了解一下screen
如有疑问,请追问。
我要举报
如以上问答内容为低俗/色情/暴力/不良/侵权的信息,可以点下面链接进行举报,我们会做出相应处理,感谢你的支持!
点此我要举报以上问答信息
推荐资讯