les MetaCités - logo

Cron : le scheduler de Linux (Unix)

Cette page est moche ?
Cette page est directement issue d'un import depuis un autre système de gestion de site web (SPIP). Elle n'a pas été vérifiée et peut vous paraître un peu moche.
Je la corrige dès que j'ai 5 minuites :-)
Stéphane Le Solliec


Cron est un programme tournant en tache de fond à qui l'on peut demander le lancement de taches régulières. Ainsi, si vous voulez sauvegarder un répertoire tous les jours à 5h23 du matin, c'est cron qu'il faudra utiliser.


Utilisation simple

Cron est un programme qui s'utilise en ligne de commande. Bien qu'elles existent certainement par dizaines, je ne connais aucune interface graphique pour cron. Les commandes sont simples.

Voila, personnellement, je connais aucune autre commande.

La syntaxe de votre fichier mycron.txt

/votre/commande/shell peut etre n'importe quelle commande que vous taperiez dans un shell. Ca peut aussi être l'adresse d'un shell script. Pour ma part, en général, je mets l'adresse d'un shell script programmé en PHP, puisque c'est le langage que je connais le mieux, mais ça peut etre du sh, perl, c, etc ...

Quand on met une étoile *, ça veut dire, tout le temps. Ainsi, 5 étoiles ça veut dire :

Quelques autres exemples

Extrait d'un man crontab :

Individual fields may contain a time, a time range, a time range with a skip factor, a symbolic range for the day of week and month in year, and additional subranges delimited with commas.

Blank lines in the crontab or lines that begin with a hash
(#) are ignored. If you specify both a day in the month
and a day of week, the result is effectively ORd... the
crontab entry will be run on the specified day of week and
on the specified day in the month.

  1. MIN HOUR DAY MONTH DAYOFWEEK COMMAND

_ # at 6:10 a.m. every day
_ 10 6 * * * date

  1. every two hours at the top of the hour

_ 0 */2 * * * date

  1. every two hours from 11p.m. to 7a.m., and at 8a.m.

_ 0 23-7/2,8 * * * date

  1. at 11:00 a.m. on the 4th and on every mon, tue, wed

_ 0 11 4 * mon-wed date

  1. 4:00 a.m. on january 1st

_ 0 4 1 jan * date

  1. once an hour, all output appended to log file

_ 0 4 1 jan * date >>/var/log/messages 2>&1

The command portion of the line is run with <code>/bin/sh -c command</code> and may therefore contain any valid bourne shell command. A common practice is to run your command with exec to keep the process table uncluttered. It is also common to redirect output to a log file. If you do not, and the command generates output on stdout or stderr, the result will be mailed to the user in question. If you use this mechanism for special users, such as UUCP, you may want to create an alias for the user to direct the mail to someone else, such as root or postmaster.

Commentaires

http://www.visualcron.com - A task scheduler for Windows
mrd, le 2005-05-26 à 21h36

Ecrire votre commentaire

Vous devez vous connecter pour pouvoir ajouter un commentaire.

MetaCités blog wiki changements pages se connecter

Projets en cours

MetaWiki KarmaOS Bookorati

Metadata

dernière modif :
2003-02-19 14h47
par : sls

Outils

diff. historique editer admin

Tags

javascript [18]
gratuit [16]
php [15]
Mac [14]
Mac OS X [13]
mysql [8]
logiciel [8]
open-source [8]
webware [8]
css [7]
rss [6]
linux [6]
HTML [5]
weblog [5]
graphisme [4]
DHTML [4]
OVH [4]
python [4]
Apple [4]
wiki [4]
tous les tags
MetaWiki : hébergement de wikis, wiki hosting.