如何让 unix 脚本每 15 秒运行一次? [英] How to get a unix script to run every 15 seconds?

查看:28
本文介绍了如何让 unix 脚本每 15 秒运行一次?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I've seen a few solutions, including watch and simply running a looping (and sleeping) script in the background, but nothing has been ideal.

I have a script that needs to run every 15 seconds, and since cron won't support seconds, I'm left to figuring out something else.

What's the most robust and efficient way to run a script every 15 seconds on unix? The script needs to also run after a reboot.

解决方案

I would use cron to run a script every minute, and make that script run your script four times with a 15-second sleep between runs.

(That assumes your script is quick to run - you could adjust the sleep times if not.)

That way, you get all the benefits of cron as well as your 15 second run period.

Edit: See also @bmb's comment below.

这篇关于如何让 unix 脚本每 15 秒运行一次?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆