Reputation: 959
I have a bash script who is use to backup my apache directories. When I'm root and I excecute my script he work fine (my directory is copied). But when I create a cron, my script is launched but the backup is not moved... Why ?
My cron job: 0 12 * * * /home/dim/backup/backup.sh -mail
My script:
$TMP_NAME="backup"
mv -f $TMP_NAME.tar.gz /test/
The directory "test" and "backup" have -r 777 rights
Thanks you !!
Upvotes: 1
Views: 2593
Reputation: 158060
The working directory of a script executed by cron is the file system root -> /
. You need to use the full path to the file:
$TMP_NAME="/full/path/to/backup"
mv -f $TMP_NAME.tar.gz /test/
Upvotes: 2