问题描述
我已经看过一些解决方案,包括观看和简单地在后台运行一个循环(和睡觉)脚本,但没有什么是理想的。一个需要每15秒运行一次的脚本,而且因为cron不支持秒,我还是想找出别的东西。
最强大和高效的方法在unix上每15秒运行一个脚本?
我会使用cron每分钟运行一个脚本,
(假设您的脚本运行速度快 - 如果没有,您可以调整睡眠时间。)
这样,你就可以得到 cron
的所有好处以及15秒的运行时间。
修改:另请参阅以下@ bmb的注释。
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秒?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!