shell脚本实现每秒执行一次任务

栏目: 服务器 · Linux · 发布时间: 8年前

内容简介:有时候我们需要每秒执行一次命令,通过linux自带的cron却不能实现,新版的cron据说可以精确到秒。很简单的,通过下面的方法,你也能每秒执行一次自己想要的任务了

有时候我们需要每秒执行一次命令,通过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

以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Complexity and Approximation

Complexity and Approximation

G. Ausiello、P. Crescenzi、V. Kann、Marchetti-sp、Giorgio Gambosi、Alberto M. Spaccamela / Springer / 2003-02 / USD 74.95

This book is an up-to-date documentation of the state of the art in combinatorial optimization, presenting approximate solutions of virtually all relevant classes of NP-hard optimization problems. The......一起来看看 《Complexity and Approximation》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具