Portal Home > Knowledgebase > Articles Database > cronjob not running
cronjob not running
Posted by HD Fanatic, 04-28-2011, 04:50 PM |
I created a mysql backup script and added to the crontab but for some reason, it does not run at all. If I run it manually, like ./mysqlbackup.sh it's fine.
I wanted it to run at 4:40pm everyday. Here's the line from crontab -l
40 16 * * * ./backups/mysqlbackup.sh > /dev/null 2>&1
-rwxr-xr-x 1 root root 870 Apr 26 15:35 mysqlbackup.sh
TIA.
|
Posted by relichost, 04-28-2011, 05:10 PM |
Hi
this ./backups/mysqlbackup.sh > /dev/null 2>&1
should be /path/backups/mysqlbackup.sh > /dev/null 2>&1
Ie dont start with the .
Thanks
PS take of the dev null until you know it works then you'll see why it fails.
|
Posted by relichost, 04-28-2011, 05:11 PM |
also have you given it Execute permission ?
|
Posted by HD Fanatic, 04-28-2011, 07:56 PM |
I tried without the . in front of the path before. Already gave it execute permission with: chmod +x backupmysql.sh
|
Posted by whmcsguru, 04-28-2011, 09:10 PM |
Then you did something wrong, or your script isn't compatible to run via cron.
if you run /path/to/script/script.sh , then it should work just fine. take off the > /dev/null 2>&1 part at the end and you'll see what's going wrong, in mail.
Make sure you have the root password for MySQL in your script, that could very easily be what's stopping it from running. When you're logged in, it will run, as you've got the environment set (ie: mysql configs), but when you're not, it will have issues as it's not.
|
Add to Favourites Print this Article
Also Read
Cheapest? (Views: 732)
windows share (Views: 650)