如何设置 cron 每一个半小时运行一次某些命令? [英] How can I set cron to run certain commands every one and a half hours?

查看:53
本文介绍了如何设置 cron 每一个半小时运行一次某些命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何设置 cron 每一个半小时运行一次特定命令?

How can I set cron to run certain commands every one and a half hours?

推荐答案

在普通 cron 中使用单个表达式是不可能的.

That's not possible with a single expression in normal cron.

不修改代码的最佳做法是:

The best you could do without modifying the code is:

0 0,3,6,9,12,15,18,21 * * *  [cmd]
30 1,4,7,10,13,16,19,22 * * * [cmd]

这些可能是可压缩的,具体取决于您必须使用的 cron 版本:

These might be compressible, depending on the version of cron you have to:

0 */3 * * * [cmd]
30 1-23/3 * * * [cmd]

这篇关于如何设置 cron 每一个半小时运行一次某些命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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