gpt4 book ai didi

cron - 如何为每天在某个时间执行的 hangfire 作业创建 cron 表达式

转载 作者:行者123 更新时间:2023-12-04 00:12:31 27 4
gpt4 key购买 nike

我是 cron 表达式的新手。我只需要知道如何为 Hangfire 中的重复作业创建 cron,该作业在每 1 天下午 5 点、凌晨 1 点、下午 2 点 45 分执行

了解到 Hangfire 也接受标准 CronExpression,我尝试探索此频率的 cron 表达式,但找不到适合它的 - https://en.wikipedia.org/wiki/Cron
我知道这 15 分钟将如何完成? */15 * * * *
我需要每天运行它。

最佳答案

cronjob schedular 使用的一般语法是:

# Execute the <b>command</b> every minute of every day.
* * * * * command

cronjob schedular 使用的所有字段的说明:
# field #   meaning        allowed values
# ------- ------------ --------------
# 1 minute 0-59
# 2 hour 0-23
# 3 day of month 1-31
# 4 month 1-12 (or names, see below)
# 5 day of week 0-7 (0 or 7 is Sun, or use names)

可以使用八个特殊字符串之一来代替前五个字段:
string         meaning
------ -------
@reboot Run once, at startup.
@yearly Run once a year, "0 0 1 1 *".
@annually (same as @yearly)
@monthly Run once a month, "0 0 1 * *".
@weekly Run once a week, "0 0 * * 0".
@daily Run once a day, "0 0 * * *".
@midnight (same as @daily)
@hourly Run once an hour, "0 * * * *".

要在使用间隔/后重复作业:
*/15 * * * * command

# This will execute the command after every 15 minutes.

为了在特定时间执行作业,可以使用“,”:
* 2,20 * * * command

# This will execute the job every minute but at the hours 2 AM and 8 PM.

希望能解开你的疑惑。

关于cron - 如何为每天在某个时间执行的 hangfire 作业创建 cron 表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43065883/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com