Cron job not working - Ubuntu
Good afternoon,
I manage a vbulletin forum board and I would like to schedule a weekly backup using cron. I was following a guide that allowed me to do so, but the cron job will not run. Guide followed: http://www.backuphowto.info/how-back...ly-linux-users I made a txt file on my pc with the following info: Code:
02 16 * * 4 mysqldump --opt -Q -uUSERNAME -pPASSWORD thetz | gzip > /home/usr/public_html/backups/database2_`date '+%m-%d-%Y'`.sql.gz crontab weeklybackup.txt I then restarted cron service cron restart I type contab -l (to show any jobs listed) and the command did show up Code:
root@thetz:/var/log# crontab -l If I type the command on its own Code:
mysqldump --opt -Q -uUSERNAME -pPASSWORD thetz | gzip > /home/usr/public_html/backups/database2_`date '+%m-%d-%Y'`.sql.gz Can anyone help me out as to why the job did not run? Please let me know if you need more info. I'm very new to linux but I do have some basic DOS experience so typing commands is not that scare :P. Thanks in advanced. |
Welcome to LQ
Since cron uses a limited path, you need to use the whole path to the commands and files. Kind regards |
Quote:
|
instead of
Code:
gzip Code:
/bin/gzip Code:
mysqldump Code:
whereis mysqldump |
Cron log is named /var/log/cron.log. You should browse through it, check messages timed with a moment your command should run.
|
Quote:
Code:
root@thetz:/var/log# dir |
ps -e | grep cron to check if cron is running.
|
Quote:
Code:
root@thetz:/etc# ps -e | grep cron |
It is. So run crontab -r, then add * * * * * echo `date` >> ~/out to your crontab.
This should add a date string to ~/out file once a minute. It's fairly errorproof command, simply to check, if cron runs jobs at all. |
Quote:
I'm doing this all through putty on my windows 7 pc. please forgive my noobiness |
Don't mind. Just add date to cron to see if it works.As you do it, wait some minutes, then do cat ~/out to see, if there are date strings. If it is, then cron is ok, it's something with your command.
|
Quote:
just tried what you asked me to do and it didn't output any dates Code:
root@thetz:/etc# crontab -l |
It's interesting.
Can you add same string to global crontab /etc/crontab. Modify it slightly * * * * * root echo `date` >> ~/out Then as usual, wait for some minutes, then check cat ~/out. |
Quote:
Code:
root@thetz:/etc# crontab -r |
No. This string * * * * * root echo `date` >> ~/out add to /etc/crontab file.
|
All times are GMT -5. The time now is 04:29 PM. |