Skip to content
Advertisement

database and wordpress backup cron job

i want to run a cron job that back ups my mysql database and my wordpress files once a day from the hostgator cpanel.

i found a sample script and edited the parameters with my information but it doesn’t seem to be working properly. I don’t have much experience with cron jobs so i’m not sure what all my issues are.

i have the .sh file named, backups.sh, saved in the home directory and have a folder named backups with subfolders database and wordpress.

this is the .sh file. i replaced {my info} with my credentials and filled out everything for my database info:

JavaScript

Here is what I have for the command line:

JavaScript

i get an email after the cron job executes and it notifies me saying, “No such file or directory”, along with a bunch of command not found.

Advertisement

Answer

cron does not always have the same PATH variable as your login shell, and therefore cannot always locate the executable for things like mysqldump or even tar.

I recommend using the full path to each command, ie: /usr/bin/mysqldump instead of just mysqldump. You can easily determine what the path is by using the which command.

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement