| Offline |
| Senior Member |
 |
Joined: Sat Feb 25, 2012 4:44 pm Posts: 71
Website: http://inhomeitsupport.com
|
|
|
I have a shell script that I want cron to run as root. Where is the best to put the script? I put it in the root directory and pointed cron to run it but it cant find it.
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=
MYSQL_BACKUP_DIR=/home/mike/mysql
BACKUP_LOG=/home/mike/mysql/backup.log
date +"%Y-%m-%d %X" > $BACKUP_LOG
# backup musql databases
/usr/bin/mysqldump --user=$MYSQL_USER --password=$MYSQL_PASSWORD --single-transaction --skip-lock-tables drupal6 | bzip2 -c > $MYSQL_BACKUP_DIR/drupal6-$(date -I).sql.bz2
date +"%Y-%m-%d %X" >> $BACKUP_LOG
# send email
mailx -s "Micro: Backup Log" < $BACKUP_LOG
|
|