0

i am setting cron job on centos.

*/10 * * * * /root/var/mysqlbackup.sh

/etc/my.cnf

/usr/local/bin/mysqlbackup.py (file permission is 755)

/var/mysqlbackup.sh

content of mysqlbackup.sh:

#! /bin/sh
cd  usr/local/bin
python mysqlbackup.py --cnf /etc/my.cnf --todir /var/backup

while its working manually. but its not working in cron job and i am not getting any error.

4

2 回答 2

0

First of all add set -x at the beginning of mysqlbackup.sh it will turn your script in debug mode.

Launch a terminal and type tail -f /var/log/messages to get debug info from your script (when launched through cron).

After launch another terminal and tail -f /var/log/cron then you will see if anything goes weird with your cron.

于 2014-03-03T10:03:55.667 回答
0

Update your sh file path :

*/10 * * * * /var/mysqlbackup.sh > /var/log/yourloggilename.log

Note: log file must have 755 permissions.

content of mysqlbackup.sh:

echo "Running.."
cd  /usr/local/bin
echo "backup file is creating...."
python mysqlbackup.py --cnf /etc/my.cnf --todir /var/backup
echo "backup file created"
于 2014-03-03T12:28:33.340 回答