linux怎么重复命令,在Linux中,自动重复命令

问题描述

是否有可能在linux命令行中每n秒重复一次命令。

例如,假设我有一个导入运行,我正在做

ls -l

检查文件大小是否增加。我想有一个命令让它自动重复。

最佳解决思路

每5秒观看一次……

watch -n 5 ls -l

如果您希望直观地确认更改,请在ls命令之前附加--differences。

根据OSX手册页,还有

The –cumulative option makes highlighting “sticky”, presenting a running display of all positions that have ever changed. The -t or –no-title option turns off the header showing the interval, command, and current time at the top of the display, as well as the following blank line.

Linux /Unix手册页可以找到here

次佳解决思路

while true; do

sleep 5

ls -l

done

第三种解决思路

“watch”不允许Busybox中的分数秒,而”sleep”则不允许。如果这对您很重要,请尝试以下方法:

while true; do ls -l; sleep .5; done

第四种思路

sleep已经返回0。因此,我正在使用:

while sleep 3 ; do ls -l ; done

这比mikhail的解决方案略短。一个小缺点是它在


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部