我是cron表达的新手.我需要知道如何在Hangfire中创建cron,每隔1天在下午5点,凌晨1点,下午2点45分执行
了解Hangfire也接受标准的CronExpression,我已经尝试过探索这个频率的cron表达式,但是找不到它 - https://en.wikipedia.org/wiki/Cron 我知道如何在15分钟内完成?*/15****我需要每天运行它.
小智 25
cronjob调度程序使用的一般语法是:
# Execute the <b>command</b> every minute of every day.
* * * * * command
Run Code Online (Sandbox Code Playgroud)
cronjob调度程序使用的所有字段的说明:
# 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)
Run Code Online (Sandbox Code Playgroud)
可以使用八个特殊字符串中的一个来代替前五个字段:
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 * * * *".
Run Code Online (Sandbox Code Playgroud)
在间隔/使用后重复作业:
*/15 * * * * command
# This will execute the command after every 15 minutes.
Run Code Online (Sandbox Code Playgroud)
为了在特定时间执行作业,可以使用:
* 2,20 * * * command
# This will execute the job every minute but at the hours 2 AM and 8 PM.
Run Code Online (Sandbox Code Playgroud)
希望能清除你的疑虑.