I have a couple of cron
jobs set up to maintain a local copy of a remote database.
The first one downloads the latest version of the database from the remote machine, which runs every day and is working fine.
The second one imports the downloaded data, however it is not working.
The job is just a simple shell script:
#!/bin/bash
mysql -u root -mypass -h localhost my_db < my_db.sql
The cron task is set up like this:
0 8 * * * bash /home/lampadmin/cron/my_db.sh
If I run the shell script manually, it works OK.
What can I do to find out why it is not working through cron?
cron
? My guess is that you are falling foul ofcron
's very spartan environment. Try giving the full path to themysql
binary in the script and see if that helps.2>&1 /var/log/myscript.log
at the end of the crontab line to see what happens during the script execution:0 8 * * * /home/lampadmin/cron/my_db.sh 2>&1 /var/log/myscript.log