在00h和13:30每天执行crontab两次

编程入门 行业动态 更新时间:2024-10-24 21:20:02
本文介绍了在00h和13:30每天执行crontab两次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想在每天的00:00和13:30执行一个脚本,所以我写:

i want to execute a script twice daily at 00:00 and 13:30 so i write :

0,30 0,13 * * *

这似乎对我来说是错误的,因为这样, 00:00,00:30,13:00和13:30。任何想法?

it seems wrong for me, because like this, the script will fire at 00:00 , 00:30 , 13:00 and 13:30. Any idea ?

推荐答案

为什么不放两个cron条目?一个是00:00,一个是13:30?我不认为你可以在一个条目中做你想要的,因为两分钟定义将适用于两个小时定义(如你所确定的)。

Why not put in two cron entries ? One for 00:00 and one for 13:30 ? I don't think you can do what you want in one entry, since the two minute definitions will apply for both hour definitions (as you've identified).

另一种方法是在00:00执行一个脚本。该脚本将执行原始脚本,然后等待13.5小时,然后再次执行该脚本。这很容易通过一个简单的sleep命令,但我认为这是不直观的,我不知道 cron 如何管理这样长时间运行进程(如果你编辑 crontab - 会杀死生成的作业等等)。

The alternative is perhaps to execute one script at 00:00. That script would execute your original script, then wait 13.5 hours and then execute that script again. It would be easy to do via a simple sleep command, but I think it's unintuitive, and I'm not sure how cron manages such long running processes (what happens if you edit the crontab - does it kill a spawned job etc.)

更多推荐

在00h和13:30每天执行crontab两次

本文发布于:2023-11-27 05:20:47,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1636764.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:两次   crontab

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!