Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Mon Mar 12, 2012 4:38 pm 
Offline
Senior Member
User avatar

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


Top
   
 Post subject:
PostPosted: Mon Mar 12, 2012 5:00 pm 
Offline
Senior Newbie

Joined: Wed Feb 22, 2012 12:04 pm
Posts: 6
Website: http://asininetech.com
you can put it in root's home dir like so

/root/mysqlbackup.sh


Top
   
 Post subject: Thanks
PostPosted: Mon Mar 12, 2012 5:16 pm 
Offline
Senior Member
User avatar

Joined: Sat Feb 25, 2012 4:44 pm
Posts: 71
Website: http://inhomeitsupport.com
I will give it a try


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: nqservices and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group