# shell script and crontab problem



## sand_man (Jan 18, 2012)

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

```
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:

```
#!/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...


----------



## wblock@ (Jan 18, 2012)

The Interrupted Unix FAQ, #2.

More specifically, the crontab path probably doesn't include the location of mysqldump.


----------



## sand_man (Jan 18, 2012)

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


----------



## DutchDaemon (Jan 18, 2012)

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.


----------

