Chinaunix首页 | 论坛 | 博客
  • 博客访问: 376404
  • 博文数量: 166
  • 博客积分: 1972
  • 博客等级: 上尉
  • 技术积分: 1845
  • 用 户 组: 普通用户
  • 注册时间: 2010-07-19 21:16
文章分类

全部博文(166)

文章存档

2013年(7)

2010年(159)

分类:

2010-10-26 22:51:14

有时候我们需要每秒执行一次命令,通过linux自带的cron却不能实现,新版的cron据说可以精确到秒。

很简单的,通过下面的方法,你也能每秒执行一次自己想要的任务了:)

 

1.编写shell脚本

mkdir /root/bin

vi /root/bin/gaojinbo.sh
#!/bin/sh

while [ true ]; do
/bin/sleep 1
/bin/date >>/tmp/date.txt
done

 

2.后台运行

nohup /root/bin/gaojinbo.sh &

 

3.确认每秒执行

tail -f /tmp/date.txt 

 

完成!



k@ygsi:/cus$ while true ; do sleep 1 ; du mozilla-central/ --max-depth=1; du -h mozilla-central/ --max-depth=1;echo $'\t'; done

k@ygsi:/cus$ while true ; do sleep 1 ; du mozilla-central/ --max-depth=1; du -h mozilla-central/ --max-depth=1;echo $'\t\n'; done

阅读(2884) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~