2017-03-28 127 views
-1

我是cron表達式的新手。我需要知道如何在Hangfire中爲每個1日下午5點後執行的重複作業創建cron,1下午2點45分如何在某個時間爲每天執行的hangfire作業創建cron表達式

瞭解Hangfire也接受標準CronExpression,我試過探索cron表達式的這個頻率,但是找不到一個它 - https://en.wikipedia.org/wiki/Cron 我知道15分鐘後會怎麼做? */15 * * * * 我需要每天運行它。

+0

什麼**關於'man crontab'的具體**不清楚,你沒有通過簡單的搜索找到解釋? – Olaf

回答

2

通過的cronjob程序器所使用的一般語法是:

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

通過的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) 

相反前五場,八個特殊字符串一個能被使用:

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. 

爲了在特定的時間執行作業,可以B中:

* 2,20 * * * command 

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

。希望清除你的疑慮。

+0

感謝您的支持。 –

+0

喜歡如果我想在一天中兩次運行一項工作(上午6點和下午6點) 玉米會像* 6,18 * * * –

相關問題