Linux - Server This forum is for the discussion of Linux Software used in a server related context. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
06-15-2011, 12:01 PM
|
#1
|
Member
Registered: Oct 2005
Posts: 542
Rep:
|
cron not running
Hi, cron on one of my boxes isn't running and I failed to determine why. Here are what I have found so far:
[backup@db mysql_backup]$ date
Wed Jun 15 09:04:06 PDT 2011
[backup@db mysql_backup]$ crontab -e
crontab: installing new crontab
[backup@db mysql_backup]$ crontab -l
6 9 * * * /home/backup/scripts/mysql_backup.sh > /home/backup/scripts/mysql_backup.log
[backup@db mysql_backup]$ date
Wed Jun 15 09:04:29 PDT 2011
[backup@db mysql_backup]$ su
Password:
[root@db mysql_backup]# tail -f /var/log/cron
Jun 15 09:04:15 db crontab[16778]: (backup) BEGIN EDIT (backup)
Jun 15 09:04:23 db crontab[16778]: (backup) REPLACE (backup)
Jun 15 09:04:23 db crontab[16778]: (backup) END EDIT (backup)
Jun 15 09:04:27 db crontab[16780]: (backup) LIST (backup)
Jun 15 09:05:01 db crond[2739]: (backup) RELOAD (cron/backup)
Last edited by grob115; 06-15-2011 at 12:09 PM.
|
|
|
06-15-2011, 12:05 PM
|
#2
|
LQ Guru
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509
|
Apparently there is no problem in the crontab entry. The only thing coming in mind is that when you edit the crontab you have to put a time specification which is at least two minutes after the current time: as you can see from the cron.log at 4:29 the cron daemon has reloaded the crontab, but it will not execute the crontab entry until 4:29 on the next day. If you edit the crontab at 4:28 you have to set the job at 4:30 in order to run it (almost) immediately.
|
|
|
06-16-2011, 12:16 PM
|
#4
|
Member
Registered: Oct 2005
Posts: 542
Original Poster
Rep:
|
colucix, thanks. However, from what I can see in the cron log is that at 09:05 the cron has been reloaded. Now if the job is set to run at 09:06, it should run the minute after it reloaded but it doesn't.
Now the most interesting thing is that it did run the day after but not at the scheduled time. I have since scheduled it to run at 04:00 but it ended up running at 01:00 as per the log. I'm totally lost on this one but will monitor it for another day to see.
|
|
|
06-16-2011, 06:51 PM
|
#5
|
Senior Member
Registered: Jan 2010
Location: SI : 45.9531, 15.4894
Distribution: CentOS, OpenNA/Trustix, testing desktop openSuse 12.1 /Cinnamon/KDE4.8
Posts: 1,144
|
hi,
as I can see you put your cron for user [backup@db mysql_backup]
try put it as 'root' and see what happens
|
|
|
06-17-2011, 10:07 AM
|
#6
|
Member
Registered: Oct 2006
Posts: 179
Rep:
|
What is the permission and ownership of the file mysql_backup.sh ?
Also, to take mysqlbackup, you will need to specify the root password of mysql in that script. Have you specified the root password in that script ?
|
|
|
06-17-2011, 12:13 PM
|
#7
|
Member
Registered: Oct 2005
Posts: 542
Original Poster
Rep:
|
Hello, thanks for replying. The backup actually works and I get a dump daily. It's just that the time when it executes doesn't match the time set in the cron. Think the following explains it all. It's actually a cron for the user "backup".
Code:
[backup@db mysql_backup]$ crontab -l
0 4 * * * /home/backup/scripts/mysql_db_backup.sh > /home/backup/scripts/mysql_db_backup.log
[backup@db mysql_backup]$ su
Password:
[root@db mysql_backup]# tail -n17 /var/log/cron
Jun 16 23:01:01 db crond[22337]: (root) CMD (run-parts /etc/cron.hourly)
Jun 17 00:01:01 db crond[22468]: (root) CMD (run-parts /etc/cron.hourly)
Jun 17 01:00:01 db crond[22597]: (backup) CMD (/home/backup/scripts/mysql_db_backup.sh > /home/backup/scripts/mysql_db_backup.log)
Jun 17 01:01:01 db crond[22614]: (root) CMD (run-parts /etc/cron.hourly)
Jun 17 01:02:01 db crond[22621]: (root) CMD (run-parts /etc/cron.daily)
Jun 17 01:02:03 db anacron[22625]: Updated timestamp for job `cron.daily' to 2011-06-17
Jun 17 02:01:01 db crond[23225]: (root) CMD (run-parts /etc/cron.hourly)
Jun 17 03:01:01 db crond[23356]: (root) CMD (run-parts /etc/cron.hourly)
Jun 17 04:01:01 db crond[23487]: (root) CMD (run-parts /etc/cron.hourly)
Jun 17 05:01:01 db crond[23620]: (root) CMD (run-parts /etc/cron.hourly)
Jun 17 06:01:01 db crond[23751]: (root) CMD (run-parts /etc/cron.hourly)
Jun 17 07:01:01 db crond[23882]: (root) CMD (run-parts /etc/cron.hourly)
Jun 17 08:01:01 db crond[24011]: (root) CMD (run-parts /etc/cron.hourly)
Jun 17 09:01:01 db crond[24179]: (root) CMD (run-parts /etc/cron.hourly)
Jun 17 09:03:32 db crontab[24277]: (backup) LIST (backup)
Jun 17 09:05:02 db crontab[24325]: (root) LIST (root)
Jun 17 09:09:37 db crontab[24360]: (backup) LIST (backup)
|
|
|
All times are GMT -5. The time now is 06:41 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|