Bonjour tout le monde,
Comme d’habitude ,j’en appel à votre générosité car je suis bloqué sur le fonctionnement d’un simple script, qui fonctionne en le lançant en console, mais qui refuse de démarrer par une tâche cron.
[code]#!/bin/sh
REPERTOIRE_SOURCE="/home/chris/“
REPERTOIRE_DESTINATION=”/media/serveur/Sauvegardes/Chris/$DATE"
FICHIER="/home/chris/Documents/Scripts/fichier_perso.lst"
SYSTEME=" /boot /etc /root"
REPSYST="/media/serveur/Sauvegardes/Chris/$DATE"
DATE=date +%d_%m_%Y_%H_%M
Détecter la présence du volume de destination et interrompre l’opération si nécessaire
if [ -d “$REPERTOIRE_DESTINATION”/$DATE ]
then
echo “Le repertoire “$REPERTOIRE_DESTINATION”/${DATE} existe deja !”;
else
mkdir “$REPERTOIRE_DESTINATION”/${DATE};
fi
rsync -acuz --stats --delete --exclude-from="$FICHIER" $REPERTOIRE_SOURCE “$REPERTOIRE_DESTINATION”/$DATE
cd $REPERTOIRE_DESTINATION
tar cvzf chris$DATE.tar.gz $DATE
Début de la sauvegarde des fichiers systèmes
echo "Début de la sauvegarde des fichiers systèmes"
sleep 5
rsync -acuz --stats --delete $SYSTEME “$REPSYST”/chris_sys$DATE
sleep 5
echo ""
echo " …TERMINER… "
echo ""
exit[/code]
La tâche cron :
14 20 * * * home/chris/Documents/Scripts/Test/backup_perso_chris.sh
celle-ci ne fonctionne pas non plus :
Le cemin et les droits du fichier :
chris@chris:~/Documents/Scripts/Test$ ls -la
total 32
drwxr-xr-x 2 chris chris 4096 2008-05-12 20:04 .
drwxr-xr-x 3 chris chris 4096 2008-05-12 17:13 ..
-rwxr-xr-x 1 chris chris 1021 2008-05-12 19:08 backup_perso_chris.sh
/etc/crontab :
1 # /etc/crontab: system-wide crontab
2 # Unlike any other crontab you don't have to run the `crontab'
3 # command to install the new version when you edit this file
4 # and files in /etc/cron.d. These files also have username fields,
5 # that none of the other crontabs do.
6
7 SHELL=/bin/sh
8 PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
9
10 # m h dom mon dow user command
11 17 * * * * root cd / && run-parts --report /etc/cron.hourly
12 25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
13 47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
14 52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
15 #
/var/log/syslog:
May 13 08:43:42 chris crontab[6551]: (root) BEGIN EDIT (root)
12 May 13 08:43:58 chris crontab[6551]: (root) REPLACE (root)
13 May 13 08:43:58 chris crontab[6551]: (root) END EDIT (root)
14 May 13 08:44:01 chris /usr/sbin/cron[5605]: (root) RELOAD (crontabs/root )
15 May 13 08:44:01 chris /USR/SBIN/CRON[6555]: (root) CMD (home/chris/Documents/Scripts/Test/backup_perso_chris.sh)
- J’ai éssayé en changeant le SHELL en : SHELL=/bin/bash
- Il fonctionne très très bien à la mano…
Si quelqu’un avait une merveilleuse idée
merci de votre aide !