On Fri, Apr 24, 2015 at 2:29 PM, Ajeesh Kannan <ajeeshbkan...@gmail.com> wrote: > Hi, > > my backup script is working when this run manually and in cron jobs. But > the script is not taking mysql dump when this is added in /etc/cron.hourly >
put your own one line cron file in /etc/cron.d (read 'man 5 crontab') to call your script. > ++++++ > while read x ; do > mysqldump ${x} > "/home/backup/TEST/${x}_`date +%d-%m-%Y`.sql" > if [ "$?" -eq "0" ] string comparison should be quoted, numeric comparison should be unquoted e.g if [ $? -eq 0 ] > echo "$x backup is OK" >> $STATUSFILE > else > echo "##### WARNING: ERROR ##### $x backup failed" >> $STATUSFILE > fi > done</etc/cron.hourly/dbfile Why is the content of the 'dbfile' and why have put it in /etc/cron.hourly? Alternately, you can declare a local variable "x=db1 db2 db3 dnN" in the script itself and use the "for n in ${x}; do blah blah; done" > ++++++++++ > > Also tried with mysqldump ${x} > /home/backup/TEST/${x}_`date +%d-%m-%Y`.sql The symbol '%' has a special meaning to cron so you need to escape it i.e use \. (RTFM 'man 5 crontab'). BTW a lot of people trip on "%" symbol in cron tab entries. HTH -- Arun _______________________________________________ ILUGC Mailing List: http://www.ae.iitm.ac.in/mailman/listinfo/ilugc ILUGC Mailing List Guidelines: http://ilugc.in/mailinglist-guidelines