shell script and crontab problem

I am trying to do a scheduled backup of a mysql database. The script I have works as intended when I run it directly like this
Code:
sh /root/scripts/glpi_backup
But if I let crontab run the script, either from /root/scripts or from /etc/periodic/daily it still produces the gzipped sql file but it is empty.
This is the contents of the script:
Code:
#!/bin/sh
mysqldump -u root glpi | gzip > /mnt/johnt01/glpi_backup/glpi_backup_`date +%d-%m-%Y`.sql.gz

I'm probably missing something really silly here...
 
I did think of that after I posted and I still couldn't get it to work. But after trying a few different things and coming back to it again it seems to be working. I must have still been missing something.
Thanks for the help :)
 
Still: either always use full path names to every single command in a script that's executed by cron, or put an extended PATH at the top of the crontab that includes all paths to all commands used.
 
Back
Top