Home  >  Article  >  Backend Development  >  cron定时5秒运行

cron定时5秒运行

WBOY
WBOYOriginal
2016-06-06 20:49:151247browse

linux下定时最小为1分钟,怎么能按秒定时呢,求解

回复内容:

linux下定时最小为1分钟,怎么能按秒定时呢,求解

写个 daemon 程序,类似这样子:

<code>#!/bin/sh

while true; do
  do_work &
  sleep 5
done
</code>

或者有 systemd 的话,systemd.timer 是支持秒级精度的。

看下之前写的一个开源项目,可以满足你的需求

https://github.com/hfcorriez/croon

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn