dbx修改running程序pid等

AIX平台实现“事后nohup”的功能, 转贴自: http://www.cublog.cn/u/739/showart.php?id=261516

例子:

1)在第一窗口中运行如下命令
vmstat -t 3 > /tmp/vmstat.out
2)在第二窗口(root权限)中运行如下命令
pid=`ps -e | grep vmstat |awk '{print $1}'`
dbx -a $pid
键入catch 1
20:13:18 ewdbkjy:[/]#ps -elf | grep vmstat
200001 A root 1331396 1429692 0 60 20 271c9400 212 f10000e313092d50 20:13:20 pts/7 0:00 grep vmstat
200001 A ewadmin 1442024 692236 0 60 20 b6e2400 336 f10000e31280e230 20:12:54 pts/5 0:00 vmstat -t 3
20:13:20 ewdbkjy:[/]#tail -f /tmp/vmstat.out
1 1 201860 726143 0 1 1 3 9 0 344 125 93 0 0 99 1 20:12:54
0 0 201867 726135 0 0 0 0 0 0 353 1024 101 0 0 99 0 20:12:57
0 0 201867 726135 0 0 0 0 0 0 352 1095 100 0 1 99 0 20:13:00
0 0 201867 726135 0 0 0 0 0 0 357 1019 101 0 0 99 0 20:13:03
0 0 201867 726135 0 0 0 0 0 0 354 1089 98 0 0 99 0 20:13:06
0 0 201866 726136 0 0 0 0 0 0 357 1057 108 0 0 99 0 20:13:09
0 0 201866 726136 0 0 0 0 0 0 356 1112 101 0 0 99 1 20:13:12
0 0 201866 726136 0 0 0 0 0 0 352 995 101 0 0 99 0 20:13:15
0 0 201866 726136 0 0 0 0 0 0 355 1123 105 0 0 99 0 20:13:18
0 0 201866 726136 0 0 0 0 0 0 362 1379 113 0 0 99 0 20:13:21
0 0 201906 726096 0 0 0 0 0 0 360 1140 103 0 0 99 0 20:13:24
^C20:13:25 ewdbkjy:[/]#pid=`ps -e | grep vmstat |awk '{print $1}'`
20:13:37 ewdbkjy:[/]#dbx -a $pid
Waiting to attach to process 1442024 ...
Successfully attached to vmstat64.
warning: Directory containing vmstat64 could not be determined.
Apply 'use' command to initialize source path.
Type 'help' for help.
reading symbolic information ...warning: no source compiled with -g
stopped in nsleep at 0x900000000273500
0x900000000273500 (nsleep+0xc8) e8410028 ld r2,0x28(r1)
(dbx) catch 1
(dbx)
3)第一窗口可以关掉了
4)回到第二窗口,依次继续键入dbx的两个子命令
cont
detach
20:13:37 ewdbkjy:[/]#dbx -a $pid
Waiting to attach to process 1442024 ...
Successfully attached to vmstat64.
warning: Directory containing vmstat64 could not be determined.
Apply 'use' command to initialize source path.
Type 'help' for help.
reading symbolic information ...warning: no source compiled with -g
stopped in nsleep at 0x900000000273500
0x900000000273500 (nsleep+0xc8) e8410028 ld r2,0x28(r1)
(dbx) catch 1
(dbx) cont
Hangup in nsleep at 0x900000000273500
0x900000000273500 (nsleep+0xc8) e8410028 ld r2,0x28(r1)
(dbx) detach
20:14:01 ewdbkjy:[/]#
5)检查一下效果
20:14:01 ewdbkjy:[/]#ps -elf | grep vmstat
200001 A root 1347672 1429692 1 60 20 d9a3400 212 f10000e313092d50 20:14:13 pts/7 0:00 grep vmstat
240011 A ewadmin 1442024 1 0 60 20 b6e2400 336 f10000e315037d30 20:12:54 - 0:00 vmstat -t 3
20:14:13 ewdbkjy:[/]#tail -f /tmp/vmstat.out
0 0 201906 726096 0 0 0 0 0 0 360 1140 103 0 0 99 0 20:13:24
0 0 201866 726136 0 0 0 0 0 0 353 1008 104 0 0 99 0 20:13:27
0 0 201866 726136 0 0 0 0 0 0 353 1148 106 0 0 99 0 20:13:30
0 0 201866 726136 0 0 0 0 0 0 354 1022 106 0 0 99 0 20:13:33
0 0 201866 726136 0 0 0 0 0 0 355 1151 103 0 0 99 0 20:13:36
0 0 201376 726628 0 0 0 0 0 0 356 581 108 0 0 99 1 20:14:02
0 0 201403 726601 0 0 0 0 0 0 353 1086 98 0 0 99 0 20:14:05
0 0 201403 726601 0 0 0 0 0 0 352 1036 95 0 0 99 0 20:14:08
0 0 201403 726601 0 0 0 0 0 0 350 1031 96 0 0 99 0 20:14:11
0 0 201403 726601 0 0 0 0 0 0 360 1373 106 0 0 99 0 20:14:14
kthr memory page faults cpu time
----- ----------- ------------------------ ------------ ----------- --------
r b avm fre re pi po fr sr cy in sy cs us sy id wa hr mi se
0 0 201444 726560 0 0 0 0 0 0 353 1063 101 0 0 99 0 20:14:17
0 0 201444 726560 0 0 0 0 0 0 354 1041 102 0 0 99 0 20:14:20
0 0 201444 726560 0 0 0 0 0 0 356 1062 106 0 0 99 0 20:14:23
^C20:14:24 ewdbkjy:[/]#

可以看到1442024的PPID从692236变成1了,/tmp/vmstat.out仍在不断增大,跟nohup的效果一模一样。估计dbx这个命令以后会被更多AIX管理员关注和使用的。
6)打扫战场
kill `ps -e | grep vmstat |awk '{print $1}'`; rm /tmp/vmstat.out[@more@]

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/7570639/viewspace-905968/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/7570639/viewspace-905968/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值