Placement of shell script for cron to run
Here is my cron settings 5 0 * * * mysqlbackup.sh as you can see it not pointing to the root directory. If I run a script from my home directory like this
5 0 * * * /home/mikemysqlbackup.sh it will run but i need root to run it.
Here is the shell script I created.
!/bin/bash
bash script to backup mysql
MYSQL_USER=root
MYSQL_PASSWORD=
MYSQLBACKUPDIR=/home/mike/mysql
BACKUP_LOG=/home/mike/mysql/backup.log
date +"%Y-%m-%d %X" > $BACKUP_LOG
backup musql databases
/usr/bin/mysqldump –user=$MYSQLUSER --password=$MYSQLPASSWORD --single-transaction --skip-lock-tables drupal6 | bzip2 -c > $MYSQLBACKUPDIR/drupal6-$(date -I).sql.bz2
date +"%Y-%m-%d %X" >> $BACKUP_LOG
send email
mailx -s "Micro: Backup Log" < $BACKUP_LOG
2 Replies
/root/mysqlbackup.sh