Question

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.

Was it helpful?

Solution

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"

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top