Pages : 1
#1 Le 12/01/2007, à 16:39
- bhernieme
je n'arrive tjs pas à exécuter un script perl avec cron
Bonjour à tous,
j'ai lu attentivement la documentation du cron,
les articles écrit sur le sujet,
et je n'arrive tjs pas faire exécuter un script perl avec le cron.
j'ai suivit les conseils de la documentation, des forums, etc ...
j'ai créé un script *.sh dans lequel j'appel mon script .pl
le script sh est
----
#! /bin/bash
/home/test/ajout.pl
----
le script perl est
----
#!/usr/bin/perl -w
#
$command = "adduser test -quiet;
system ($command);
----
le fichier crontab est
----
# /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.
# This file also has a username field, that none of the other crontabs do.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# m h dom mon dow user command
17 * * * * root run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || run-parts --report /etc/cron.daily
47 6 * * 7 root test -x /usr/sbin/anacron || run-parts --report /etc/cron.weekly
52 6 1 * * root test -x /usr/sbin/anacron || run-parts --report /etc/cron.monthly
----
le fichier de configuration cron est
----
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.eTj1RT/crontab installed on Thu Jan 11 18:51:05 2007)
# (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $)
* * * * * /home/test/ajout.sh #test de script pl avec cron
----
une petite idée
NB : dans le script sh, j'ai mis comme commande mkdir /home/testcron pour vérifier que le script s'exécute au moin , il est lu par le process cron.
merci beaucoup
#2 Le 28/01/2007, à 19:11
- ToinS
Re : je n'arrive tjs pas à exécuter un script perl avec cron
bonjour,
il faut que ajout.pl soit executable ou alors ecrire le script bash comme ceci :
#!/bin/bash
perl /home/test/ajout.pl
Autre chose, il n'y a pas d'espace après le #! dans la premiere ligne !
Antoine Farnault
antoine [at] afarno . com
http://afarno.com
JID: af@jabber.org
Hors ligne