Chinaunix首页 | 论坛 | 博客
  • 博客访问: 231987
  • 博文数量: 48
  • 博客积分: 1088
  • 博客等级: 少尉
  • 技术积分: 339
  • 用 户 组: 普通用户
  • 注册时间: 2012-04-27 10:24
文章分类

全部博文(48)

文章存档

2012年(48)

我的朋友

分类: LINUX

2012-07-20 11:51:16

有时候,你期望关闭Shell 终端后,运行的作业不会退出,简单地在命令后加&是行不通的,以下总结几种处理方法:

 

1.NOHUP ------  run a command immune to hangups, with output to a non-tty
eg: 
[root@guangxi iWas]# nohup ping laibin.com.cn >/tmp/out.log 2>&1 &
[1] 7921
[root@guangxi iWas]# jobs
[1]+  Running                 nohup ping laibin.com.cn >/tmp/out.log 2>&1 &
[root@guangxi iWas]#

 

2. DISOWN ----- Without options, each jobspec is  removed  from  the  table  of  active  jobs.

 

[root@guangxi iWas]# cp -r /mnt/pspch12/iscw/iwas/u0620.46.linux/ .

[1]+  Stopped                 cp -i -r /mnt/pspch12/iscw/iwas/u0620.46.linux/ .
[root@guangxi iWas]# bg 1
[1]+ cp -i -r /mnt/pspch12/iscw/iwas/u0620.46.linux/ . &
[root@guangxi iWas]# jobs
[1]+  Running                 cp -i -r /mnt/pspch12/iscw/iwas/u0620.46.linux/ . &
[root@guangxi iWas]# disown -ah
[root@guangxi iWas]# exit

 

3.Screen


1.create a new screen: 
$ screen 
or create a new screen running in background
$ screen -dmS
2.do anything you want in this screen
3.you can exit from this screen by "ctrl+a+d" or just close the client session

eg:
[root@guangxi iWas]# screen -dmS Urumchi
[root@guangxi iWas]# ping laibin.com.cn
PING laibin.com.cn (9.181.64.233) 56(84) bytes of data.
64 bytes from laibin.com.cn (9.181.64.233): icmp_seq=0 ttl=64 time=0.397 ms
64 bytes from laibin.com.cn (9.181.64.233): icmp_seq=1 ttl=64 time=0.311 ms
64 bytes from laibin.com.cn (9.181.64.233): icmp_seq=2 ttl=64 time=1.15 ms



4.restore your screen from any box
check the screen list in your box: 
$ screen -list 
select the screen you want to restore:
$ screen -r (if only one screen available now) 
$ screen -r   (restore a specified screen which create by "-d" param )
$ screen -r (restore the screen with specified pid)  
eg:
[root@guangxi ~]# screen -list
There is a screen on:
        8530.Urumchi    (Detached)
1 Socket in /tmp/screens/S-root.

[root@guangxi ~]# screen -r Urumchi
ms
64 bytes from laibin.com.cn (9.181.64.233): icmp_seq=15 ttl=64 time=0.186 ms
64 bytes from laibin.com.cn (9.181.64.233): icmp_seq=16 ttl=64 time=0.186 ms
64 bytes from laibin.com.cn (9.181.64.233): icmp_seq=17 ttl=64 time=0.182 ms

 


4. VNC: jobs which run from VNC won't be stopped even after exit VNC. How about Kill VNC session? (Not sure)

阅读(1910) | 评论(0) | 转发(0) |
0

上一篇:gcc 参数中文手册

下一篇:vi 快捷键总结

给主人留下些什么吧!~~