查看dd命令的执行进度
来源:互联网 发布:mac模拟器玩游戏 编辑:程序博客网 时间:2024/05/06 01:10
命令
今天在commandlinefu.com网站看到这么一篇文章check the status of ‘dd’ in progress,试了下,效果很好。
现在一个终端中开启一个dd进程
dd if=/dev/zero of=/data3/test bs=1k count=1024000
然后在另外一个终端中用while来反复执行killall命令
while killall -USR1 dd; do sleep 5; done
然后就能看到间隔5秒一次的输出结果了
292289+0 records in
292288+0 records out
541861+0 records in
541860+0 records out
760037+0 records in
760036+0 records out
886602+0 records in
886601+0 records out
1007881+0 records in
1007880+0 records out
1024000+0 records in
1024000+0 records out
292288+0 records out
541861+0 records in
541860+0 records out
760037+0 records in
760036+0 records out
886602+0 records in
886601+0 records out
1007881+0 records in
1007880+0 records out
1024000+0 records in
1024000+0 records out
所执行的killall命令循环会在dd命令执行结束之后退出。
top说明
可能不熟悉linux的人会问了,为什么dd命令的进度输出要killall命令来激发呢?其实答案很简单,dd的进度输出就是这么设计的,再详细点就是dd命令在执行的时候接收到SIGUSR1信号的输出当前的读写进度,而killall命令在这里起的作用就是给dd进程发送这个信号。
killall命令,和kill命令一样,其作用是给指定的进程发送一个信号过去,不是平常所理解的仅仅是结束一个进程,就像下面摘录的man kill里面描述的一样。
DESCRIPTION
The command kill sends the specified signal to the specified process or
process group. If no signal is specified, the TERM signal is sent.
The TERM signal will kill processes which do not catch this signal.
For other processes, it may be necessary to use the KILL (9) signal,
since this signal cannot be caught.
The command kill sends the specified signal to the specified process or
process group. If no signal is specified, the TERM signal is sent.
The TERM signal will kill processes which do not catch this signal.
For other processes, it may be necessary to use the KILL (9) signal,
since this signal cannot be caught.
所以上面的”while killall -USR1 dd; do sleep 5; done”就是每隔5秒就给所有的dd命令进程发送一个USR1信号,dd命令进程接收到信号之后就打印出自己当前的进度。
因为kill命令能传递的信号不仅仅是SIGTERM(kill pid)和SIGKILL(kill -9 pid),还有很多其他的信号值,在这里面还有一个很经常用的就是SIGHUP(1)了,对于没有那些不与终端交互的守护进程(Deamon Process),通常的设计是在接收到SIGHUP信号之后就会重新读取配置文件。比如下面的
# 当你对smb.conf修改之后,运行下面的命令,修改就能生效了
# 而不用再来一个smb restart
killall -HUP smbd
# 而不用再来一个smb restart
killall -HUP smbd
- 查看dd命令的执行进度
- 查看dd命令的执行进度
- 查看dd拷贝进度
- linux下显示dd命令的进度
- Linux下显示dd命令的进度
- linux下显示dd命令的进度
- linux下显示dd命令的进度
- linux下显示dd命令的进度
- linux下显示dd命令的进度
- linux下显示dd命令的进度
- linux下显示dd命令的进度
- linux小记:查看dd进度
- dd命令显示当前进度
- 如何查看distirbution agent的执行进度
- 如何查看distirbution agent的执行进度
- 如何使用pv命令监控Linux命令的执行进度
- 查看执行命令的记录
- dd命令的测试
- ios iphone 入门 例子
- 整合SSH后出现Unable to instantiate Action, student, defined for 'add_StudentAction' in namespace '/'stude
- 2012.8.4
- 字符串的赋值和字符串数组
- 修改TabWidget字体大小、颜色、Gravity等等...
- 查看dd命令的执行进度
- 有关哥的传说(程序员版)
- 转:金山网络傅盛:移动互联网时代的矿工五法则
- MYSQL cmake 安装指南
- 虚拟机中的锁优化简介
- android contentprovider
- 再探地精排序GnomeSort
- PHP特级视频教程 笔记心得 第十二集 MySQL bin-log日志和主从复制
- Object-c 字符串处理及建立(包含一些数组的使用等)