Contenu | Rechercher | Menus

Annonce

Si vous avez des soucis pour rester connecté, déconnectez-vous puis reconnectez-vous depuis ce lien en cochant la case
Me connecter automatiquement lors de mes prochaines visites.

À propos de l'équipe du forum.

#1 Le 26/02/2011, à 17:50

laulau709

cron ???? rien ne se passe [Résolu]

Bonjour

Voila je cherche à faire executer un scripte php toutes les 2 minutes

j'ai fais crontab -e
puis j'ai ajouté cette ligne
*/2 * * * * root /usr/bin/php5 -f /var/www/cron/script.php >> /var/www/cron/log.txt

chmod 777 script.php
chown ugo+x script.php

mais rien ne se passe

et quand je lance
/usr/bin/php5 -f /var/www/cron/script.php la pas de proble mon scripte fonctionne

Si quelqu'un avais une piste merci

Dernière modification par laulau709 (Le 27/02/2011, à 00:15)

Hors ligne

#2 Le 26/02/2011, à 18:17

pode

Re : cron ???? rien ne se passe [Résolu]

Les fichiers de cron avec le nom de l'utilisateur (ici, root) ne sont pas gérés avec la commande crontab

man 5 crontab
[...]
EXAMPLE SYSTEM CRON FILE
       This has the username field, as used by /etc/crontab.
       # /etc/crontab: system-wide crontab
       # Unlike any other crontab you don't have to run the `crontab'
       # command to install the new version when you edit this file
       # and files in /etc/cron.d. These files also have username fields,
       # that none of other the crontabs do.

A mon avis, supprime la crontab créée avec la commande crontab -e, et créé un fichier directement dans /etc/cron.d

man cron
[...]
       cron also reads /etc/crontab, which is in a slightly  different  format
       (see  crontab(5)).   Additionally, cron reads the files in /etc/cron.d:
       it treats  the  files  in  /etc/cron.d  as  in  the  same  way  as  the
       /etc/crontab  file  (they  follow the special format of that file, i.e.
       they  include  the  user  field).  However,  they  are  independent  of
       /etc/crontab:  they  do  not, for example, inherit environment variable
       settings from it. The intended purpose of  this  feature  is  to  allow
       packages  that  require  finer  control  of  their  scheduling than the
       /etc/cron.{daily,weekly,monthly} directories to add a crontab  file  to
       /etc/cron.d. Such files should be named after the package that supplies
       them. Files must conform to the same naming convention as used by  run-
       parts(8):  they  must  consist solely of upper- and lower-case letters,
       digits, underscores, and hyphens.

Iil y a déjà un fichier nommé /etc/cron.d/php5 ; pour garder ton script même après une mise à jour, il vaut mieux créer un autre fichier, par exemple /etc/cron.d/php5-script

Hors ligne

#3 Le 27/02/2011, à 00:14

laulau709

Re : cron ???? rien ne se passe [Résolu]

coucou oki grande merci cela fonctionne maintenant

Hors ligne