Comment exécuter crontab job CHAQUE SEMAINE le dimanche

J'essaie de comprendre comment exécuter un travail crontab chaque semaine le dimanche. Je pense que ce qui suit devrait fonctionner, mais je ne suis pas sûr si je comprends bien. Est la suivante correct?

5 8 * * 6
209
demandé sur Tiny Giant 2013-05-23 19:25:40

5 réponses

Voici une explication du format 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

Donc, selon ce que votre {[1] } courrait 8: 05 tous les dimanches.

407
répondu Bjoern Rennhak 2017-08-23 23:47:06

Pour qu'un cron soit exécuté le dimanche, vous pouvez utiliser l'un de ces éléments:

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

5 8 représente le moment de la journée où cela se produira: 8: 05.

En général, si vous voulez exécuter quelque chose le dimanche, assurez-vous que la 5ème colonne contient le 0, 7 ou Sun. Tu avais 6, donc ça fonctionnait samedi.

Le format pour cronjobs est:

 +---------------- 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

, Vous pouvez toujours utiliser crontab.guru {[17] } en tant qu'éditeur pour vérifier vos expressions cron.

142
répondu fedorqui 2017-08-31 09:35:03

Voici le format du fichier crontab.

{minute} {heure} {jour du mois} {Mois} {Jour de la semaine} {utilisateur} {chemin d'accès au script shell}

Donc, pour courir chaque dimanche à minuit (le dimanche est généralement 0, 7 dans de rares cas):

0 0 * * 0 root /path_to_command
37
répondu xShirase 2017-10-22 12:42:48

Lorsque vous spécifiez vos valeurs cron, vous devez vous assurer que vos valeurs se situent dans les plages. Par exemple, certains cron utilisent une plage 0-7 pour le jour de la semaine où 0 et 7 représentent le dimanche. Nous n'avons pas.

Minutes: 0-59
Hours: 0-23
Day of Month: 1-31
Months: 0-11
Day of Week: 0-6
3
répondu Mendon Ashwini 2016-04-29 10:38:38

10 * * * le Soleil

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
répondu Bachan Joseph 2017-10-13 05:29:25