web-dev-qa-db-ja.com

毎週日曜日にcrontabジョブを実行する方法

私は毎週日曜日にcrontabジョブを実行する方法を見つけようとしています。私は以下がうまくいくはずだと思いますが、私が正しく理解しているかどうかはわかりません。以下は正しいですか?

5 8 * * 6
223
dev_fight

これがcrontabフォーマットの説明です。

# 1. Entry: Minute when the process will be started [0-60]
# 2. Entry: Hour when the process will be started [0-23]
# 3. Entry: Day of the month when the process will be started [1-28/29/30/31]
# 4. Entry: Month of the year when the process will be started [1-12]
# 5. Entry: Weekday when the process will be started [0-6] [0 is Sunday]
#
# all x min = */x

だからこれによるとあなたの5 8 * * 0は毎週日曜日に8:05を実行するでしょう。

432
Bjoern Rennhak

日曜日にcronを実行するには、次のいずれかを使用できます。

5 8 * * 0
5 8 * * 7
5 8 * * Sun

ここで5 8はこれが起こる日の時間を表します:8:05。

一般に、日曜日に何かを実行したい場合は、5列目に07、またはSunのいずれかが含まれていることを確認してください。 6を持っていたので、土曜日に実行されていました。

Cronjobの形式は次のとおりです。

 +---------------- minute (0 - 59)
 |  +------------- hour (0 - 23)
 |  |  +---------- day of month (1 - 31)
 |  |  |  +------- month (1 - 12)
 |  |  |  |  +---- day of week (0 - 6) (Sunday=0 or 7)
 |  |  |  |  |
 *  *  *  *  *  command to be executed

あなたはいつでも crontab.guru をあなたのcron式をチェックするためのエディタとして使うことができます。

158
fedorqui

以下は、crontabファイルのフォーマットです。

{分} {時間} {日} {月} {曜日} {ユーザ} {シェルスクリプトへのパス}

したがって、各日曜日を午前0時に実行するとします(日曜日は通常0、まれに7です)。

0 0 * * 0 root /path_to_command
38
xShirase

Cron値を指定するときには、値が範囲内にあることを確認する必要があります。たとえば、一部のcronでは、0と7の両方が日曜日を表す曜日に0から7の範囲を使用します。していません(下記参照)。

Seconds: 0-59
Minutes: 0-59
Hours: 0-23
Day of Month: 1-31
Months: 0-11
Day of Week: 0-6

参照: https://github.com/ncb000gt/node-cron

4
Mendon Ashwini

10 * * *日

Position 1 for minutes, allowed values are 1-60
position 2 for hours, allowed values are 1-24
position 3 for day of month ,allowed values are 1-31
position 4 for month ,allowed values are 1-12 
position 5 for day of week ,allowed values are 1-7 or and the day starts at Monday. 
1
Bachan Joseph
* * * * 0 

you can use above cron job to run on every week on sunday, but in addition on what time you want to run this job for that you can follow below concept :

* * * * *  Command_to_execute
- � � � -
| | | | |
| | | | +�� Day of week (0�6) (Sunday=0) or Sun, Mon, Tue,...
| | | +���- Month (1�12) or Jan, Feb,...
| | +����-� Day of month (1�31)
| +������� Hour (0�23)
+��������- Minute (0�59)
0

人間が読める形式のCronジョブ表現 crontabビルダー

0
Vytautas

@週に1度、私のためにうまく機能します。 example,add the fellowing crontab -e ,it will work in every sunday 0:00 AM @weekly /root/fd/databasebackup/week.sh >> ~/test.txt