tcl脚本循环 在linux循环执行脚本命令的多种办法

11/28 02:07:36 来源网站:seo优化-辅助卡盟平台

tcl脚本循环 在linux循环执行脚本命令的多种办法

用 Watch 命令

watch命令默认每2秒执行1次命令,例如:

# watch free -m

按键精灵脚本循环_shell脚本for循环_tcl脚本循环

shell脚本for循环_按键精灵脚本循环_tcl脚本循环

watch命令执行效果

当然辅助论坛,你可以自己指定间隔,例如tcl脚本循环,每10秒执行这个脚本

按键精灵脚本循环_shell脚本for循环_tcl脚本循环

# watch -n 10 script.sh

还有其它参数控制更多

-b – 如果命令返回非0,则 beep一下-c – 显示有ANSI的颜色代码(Interprets ANSI color sequences.)-d – 高亮变更的部分(highlights the changes in the command output.)

tcl脚本循环_shell脚本for循环_按键精灵脚本循环

例如tcl脚本循环,查看复制过来的文件大小

# cp ubuntu-15.10-desktop-amd64.iso /home/tecmint/ &
# watch -n 0.1 du -s /home/tecmint/ubuntu-15.10-desktop-amd64.iso 

tcl脚本循环_按键精灵脚本循环_shell脚本for循环

用脚本的循环关键字 for, while

例如 每秒显示一段文字

 # for i in {1..10}; do echo -n "This is a test in loop $i "; date ; sleep 1; done

shell脚本for循环_tcl脚本循环_按键精灵脚本循环

tcl脚本循环_shell脚本for循环_按键精灵脚本循环

用for循环脚本定时执行

有for一般都会有while支持,例如

# while true; do echo -n "This is a test of while loop";date ; sleep 5; done

以上就是在linux里面循环执行命令的办法,基本上 ubuntu, centos等都支持!

来源:【九爱网址导航www.fuzhukm.com】 免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!

    暂无相关资讯
tcl脚本循环 在linux循环执行脚本命令的多种办法