FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > CentOS > CentOS

 
 
LinkBack Thread Tools
 
Old 03-11-2010, 12:02 PM
"Alexander Dalloz"
 
Default crontab and/or anacrontab ?

> Is one meant to have one or the other?
> If so, which is recommended?
> I have
> --------------------------------
> [tim@helen etc]$ cat anacrontab

[ ... ]

> [tim@helen etc]$ cat crontab

[ ... ]

> I didn't write either of these,
> they must have been automatically installed.
>
> My impression is that anacrontab was ignored until recently,
> but now as far as I can see both are being read and acted on.
>
> Any enlightenment gratefully received.

> Timothy Murphy

It is pretty "normal" to have them both on CentOS.

# rpm -qf /etc/crontab
crontabs-1.10-8
# rpm -qf /etc/anacrontab
anacron-2.3-45.el5

man 8 anacron

"DESCRIPTION
Anacron can be used to execute commands periodically, with a
frequency specified in days. Unlike cron(8), it does not assume
that the machine is running continuously. Hence, it can be used
on machines that aren’t running 24 hours a day, to control daily,
weekly, and monthly jobs that are usually controlled by cron."

This should make obvious why there are both of the crontabs and in which
situations anacron runs through his tab and when cron runs through his.

Regards

Alexander



_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 03-11-2010, 12:43 PM
Timothy Murphy
 
Default crontab and/or anacrontab ?

Alexander Dalloz wrote:

> It is pretty "normal" to have them both on CentOS.
>
> # rpm -qf /etc/crontab
> crontabs-1.10-8
> # rpm -qf /etc/anacrontab
> anacron-2.3-45.el5
>
> man 8 anacron
>
> "DESCRIPTION
> Anacron can be used to execute commands periodically, with a
> frequency specified in days. Unlike cron(8), it does not assume
> that the machine is running continuously. Hence, it can be used
> on machines that aren’t running 24 hours a day, to control daily,
> weekly, and monthly jobs that are usually controlled by cron."
>
> This should make obvious why there are both of the crontabs and in which
> situations anacron runs through his tab and when cron runs through his.

Sorry, it's not at all clear to me.
The machine in question is running all the time.
Are you saying that anacron should be turned off in this case,
presumably by "chkconfig anacron off"?

1) I didn't turn it on, so presumably anacron runs by default under CentOS.

2) As far as I can tell, the duplication only started recently,
when I noticed that I was getting logwatch messages twice a day.

I have another CentOS-5.4 machine, which is also running all the time,
and as far as I can see there is no duplication on that machine.

To repeat my question, is one meant to turn anacron off
if the machine is running all the time?
Or is anacron meant to determine this in some way?
And if so, how?



--
Timothy Murphy
e-mail: gayleard /at/ eircom.net
tel: +353-86-2336090, +353-1-2842366
s-mail: School of Mathematics, Trinity College, Dublin 2, Ireland

_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 03-11-2010, 01:20 PM
"Alexander Dalloz"
 
Default crontab and/or anacrontab ?

> Sorry, it's not at all clear to me.
> The machine in question is running all the time.
> Are you saying that anacron should be turned off in this case,
> presumably by "chkconfig anacron off"?
>
> 1) I didn't turn it on, so presumably anacron runs by default under
> CentOS.
>
> 2) As far as I can tell, the duplication only started recently,
> when I noticed that I was getting logwatch messages twice a day.
>
> I have another CentOS-5.4 machine, which is also running all the time,
> and as far as I can see there is no duplication on that machine.
>
> To repeat my question, is one meant to turn anacron off
> if the machine is running all the time?
> Or is anacron meant to determine this in some way?
> And if so, how?

> Timothy Murphy

Hi Timothy,

let's take the case that you have a power failure or a scheduled
maintenance with your system for instance in the early morning hours, from
03:00am - 05:00am. cron.daily is set by default to run at 04:02am. So in
this case cron could not perform tasks like logwatch. logwatch will miss
in such a case, *if* there wouldn't be anacron which takes over the task
to run after the machine is up again (i.e. at 05:00am).

There is no need to deactivate or remove anacron. If your system runs all
the time, then anacron will not come into play. If you got actions by
anacron on one of your systems, then it either was off while cronjobs
should have run or it was in single user mode.

How anacron handles jobs is documentend in "man 8 anacron". It uses
timestamp files in /var/spool/anacron/ to control, when a job was last
performed and whether it is pending.

Regards

Alexander


_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 03-11-2010, 01:28 PM
Tony Molloy
 
Default crontab and/or anacrontab ?

On Thursday 11 March 2010 12:50:13 Timothy Murphy wrote:
> Is one meant to have one or the other?
> If so, which is recommended?
> I have
> --------------------------------
> [tim@helen etc]$ cat anacrontab
> # /etc/anacrontab: configuration file for anacron
>
> # See anacron(8) and anacrontab(5) for details.
>
> SHELL=/bin/sh
> PATH=/sbin:/bin:/usr/sbin:/usr/bin
> MAILTO=root
>
> 1 65 cron.daily run-parts /etc/cron.daily
> 7 70 cron.weekly run-parts /etc/cron.weekly
> 30 75 cron.monthly run-parts /etc/cron.monthly
> --------------------------------
> [tim@helen etc]$ cat crontab
> SHELL=/bin/bash
> PATH=/sbin:/bin:/usr/sbin:/usr/bin
> MAILTO=root
> HOME=/
>
> # run-parts
> 01 * * * * root run-parts /etc/cron.hourly
> 02 4 * * * root run-parts /etc/cron.daily
> 22 4 * * 0 root run-parts /etc/cron.weekly
> 42 4 1 * * root run-parts /etc/cron.monthly
> --------------------------------
> I didn't write either of these,
> they must have been automatically installed.
>
> My impression is that anacrontab was ignored until recently,
> but now as far as I can see both are being read and acted on.
>
> Any enlightenment gratefully received.
>

Both are typically installed as part of a CentOS install. But you only need
one or the other. Generally cron on a 24x7 machine and anacron on a laptop.
One or the otrher is mormally disabled.

cron is a fixed time schedular. I wakes up every minute and checks if there are
any jobs to be run. It checks /etc'/crontab for system crons to run and also
in /var/spool/cron for individual crons to be run.

e.g from my /etc/crontab file

22 4 * * 0 root run-parts /etc/cron.weekly

says

At 22 minutes past 4am run /etc/cron.weekly


anacron is for machines that are not up 24x7 so they could miss some of the
times when "cron jobs" were to be run. So anacron wakes up and checks the
/etc/anacrontab file. Then it runs any jobs after a certain delay period ( not
at a fixed time )

e.g from my /etc/anacrontab file

7 20 cron.weekly nice run-parts /etc/cron.weekly

says

20 minutes after waking up every 7 days run /etc/cron.weekly


Hope this helps,

Tony


--

Chief Technical Officer. Tel: +353 061-202778
Dept. of Comp. Sci.
University of Limerick.

_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 03-11-2010, 03:00 PM
Timothy Murphy
 
Default crontab and/or anacrontab ?

Tony Molloy wrote:

> anacron is for machines that are not up 24x7 so they could miss some of
> the times when "cron jobs" were to be run. So anacron wakes up and checks
> the /etc/anacrontab file. Then it runs any jobs after a certain delay
> period ( not at a fixed time )
...
> Hope this helps,

Sadly, no.

If "anacron is for machines that are not up 24x7"
then why run it on machines that are up all the time
(which I imagine is most CentOS machines)?


--
Timothy Murphy
e-mail: gayleard /at/ eircom.net
tel: +353-86-2336090, +353-1-2842366
s-mail: School of Mathematics, Trinity College, Dublin 2, Ireland

_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 03-11-2010, 03:17 PM
Timothy Murphy
 
Default crontab and/or anacrontab ?

Alexander Dalloz wrote:

> let's take the case that you have a power failure or a scheduled
> maintenance with your system for instance in the early morning hours, from
> 03:00am - 05:00am. cron.daily is set by default to run at 04:02am. So in
> this case cron could not perform tasks like logwatch. logwatch will miss
> in such a case, *if* there wouldn't be anacron which takes over the task
> to run after the machine is up again (i.e. at 05:00am).

Thanks for your response.

Actually, I wouldn't mind in the slightest if cron.daily failed to run
because the machine was down at the nominated time.
It is not as though my world depends on cron.daily running every day.
I certainly would not run another program in case that happened.

> How anacron handles jobs is documentend in "man 8 anacron". It uses
> timestamp files in /var/spool/anacron/ to control, when a job was last
> performed and whether it is pending.

Actually, "man 8 anacron" does not say that.
It says "Anacron records the date in a special timestamp file",
but it doesn't say where that file is.

I see that there are actually files /var/spool/anacron/cron.daily , etc,
on my machine listing the last day anacron ran (20100311)
But it seems that this information is not used, in my case,
I don't know why.

As I said, this duplication seems to have started recently,
and I have taken no action on this machine for months
apart from running "sudo yum update",
so I assume some update had this effect.

I have a second CentOS machine where this duplication does not occur,
even though everything seems the same as on the first machine.






--
Timothy Murphy
e-mail: gayleard /at/ eircom.net
tel: +353-86-2336090, +353-1-2842366
s-mail: School of Mathematics, Trinity College, Dublin 2, Ireland

_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 03-11-2010, 03:52 PM
Tony Molloy
 
Default crontab and/or anacrontab ?

On Thursday 11 March 2010 16:00:49 Timothy Murphy wrote:
> Tony Molloy wrote:
> > anacron is for machines that are not up 24x7 so they could miss some of
> > the times when "cron jobs" were to be run. So anacron wakes up and checks
> > the /etc/anacrontab file. Then it runs any jobs after a certain delay
> > period ( not at a fixed time )
>
> ...
>
> > Hope this helps,
>
> Sadly, no.
>
> If "anacron is for machines that are not up 24x7"
> then why run it on machines that are up all the time
> (which I imagine is most CentOS machines)?
>

It's only on if you have switched it on..
# chkconfig --list | grep anacron

will tell you if it is switched on

# chkconfig --level 35 anacon off

will switch it off. on next rebot

# service anacron stop

will stop it immediatley.

You don't need it on a machine that's up 24x7. cron should handle all your
scheduled jobs.

By the way I run centos on several of my laptops and they're not up 24x7

Tony


--

Chief Technical Officer. Tel: +353 061-202778
Dept. of Comp. Sci.
University of Limerick.

_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 03-11-2010, 04:03 PM
Tony Molloy
 
Default crontab and/or anacrontab ?

On Thursday 11 March 2010 16:17:13 Timothy Murphy wrote:
> Alexander Dalloz wrote:
> > let's take the case that you have a power failure or a scheduled
> > maintenance with your system for instance in the early morning hours,
> > from 03:00am - 05:00am. cron.daily is set by default to run at 04:02am.
> > So in this case cron could not perform tasks like logwatch. logwatch will
> > miss in such a case, *if* there wouldn't be anacron which takes over the
> > task to run after the machine is up again (i.e. at 05:00am).
>
> Thanks for your response.
>
> Actually, I wouldn't mind in the slightest if cron.daily failed to run
> because the machine was down at the nominated time.
> It is not as though my world depends on cron.daily running every day.
> I certainly would not run another program in case that happened.
>

You're world may not depend on it but those of us who run 10's of servers need
a bit more reassurance. ;-)

> > How anacron handles jobs is documentend in "man 8 anacron". It uses
> > timestamp files in /var/spool/anacron/ to control, when a job was last
> > performed and whether it is pending.
>
> Actually, "man 8 anacron" does not say that.
> It says "Anacron records the date in a special timestamp file",
> but it doesn't say where that file is.
>

They're in /var/spool/anacron. Three files cron.daily .weekly .monthly.

> I see that there are actually files /var/spool/anacron/cron.daily , etc,
> on my machine listing the last day anacron ran (20100311)
> But it seems that this information is not used, in my case,
> I don't know why.
>

That's the date anacron was last run.

> As I said, this duplication seems to have started recently,
> and I have taken no action on this machine for months
> apart from running "sudo yum update",
> so I assume some update had this effect.
>

Yum probaably updated anacron and set it to running

On my laptop

# rpm -qa --last | grep anacron
gives
cronie-anacron-1.4.3-4.fc12 Sat Feb 27 11:05:52 2010

So it was updated last on 27th Feb.

> I have a second CentOS machine where this duplication does not occur,
> even though everything seems the same as on the first machine.
>

Tony

--

Chief Technical Officer. Tel: +353 061-202778
Dept. of Comp. Sci.
University of Limerick.

_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 03-11-2010, 05:37 PM
Stephen Harris
 
Default crontab and/or anacrontab ?

On Thu, Mar 11, 2010 at 04:52:56PM +0000, Tony Molloy wrote:
> It's only on if you have switched it on..
> # chkconfig --list | grep anacron

> # chkconfig --level 35 anacon off
>
> will switch it off. on next rebot
>
> # service anacron stop
>
> will stop it immediatley.

In fact, it's not that simple; anacron isn't a persistent daemon.

The way it works is that the rc script calls anacron to catch up on
missed jobs. When anacron has finished this then it exits.

Now from regular cron you'll see /etc/cron.{daily,weekly,monthly}/0anacron
which calls "anacron -u". This simply tells anacron to update the
timestamp and does nothing else.

And that's how the boot version determines if there's work to do; if the
timestamp file is too old at boot time.

During normal operation anacron shouldn't run (except for the timestamp
updates). If it is then either it's been running since boot time
(lots of work to catchup? hung?) or else it's been incorrectly started.

So
$ chkconfig --list anacron
anacron 0ff 1ff 2n 3n 4n 5n 6ff

$ service anacron status
anacron is stopped

$ grep anacron /var/log/cron
Mar 7 04:22:02 mercury anacron[3138]: Updated timestamp for job `cron.weekly' to 2010-03-07
Mar 8 04:02:02 mercury anacron[20530]: Updated timestamp for job `cron.daily' to 2010-03-08
Mar 9 04:02:02 mercury anacron[26657]: Updated timestamp for job `cron.daily' to 2010-03-09
Mar 10 04:02:03 mercury anacron[5804]: Updated timestamp for job `cron.daily' to 2010-03-10
Mar 11 04:02:01 mercury anacron[10005]: Updated timestamp for job `cron.daily' to 2010-03-11


--

rgds
Stephen
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 03-11-2010, 09:50 PM
Robert Nichols
 
Default crontab and/or anacrontab ?

On 03/11/2010 10:17 AM, Timothy Murphy wrote:
> Alexander Dalloz wrote:
>
>> let's take the case that you have a power failure or a scheduled
>> maintenance with your system for instance in the early morning hours, from
>> 03:00am - 05:00am. cron.daily is set by default to run at 04:02am. So in
>> this case cron could not perform tasks like logwatch. logwatch will miss
>> in such a case, *if* there wouldn't be anacron which takes over the task
>> to run after the machine is up again (i.e. at 05:00am).
>
> Thanks for your response.
>
> Actually, I wouldn't mind in the slightest if cron.daily failed to run
> because the machine was down at the nominated time.
> It is not as though my world depends on cron.daily running every day.
> I certainly would not run another program in case that happened.

In that case feel free to disable anacron, but it really makes little
difference. As Stephen has pointed out, in CentOS 5 anacron runs once
when you enter any of the runlevels where it is active, runs any
overdue {daily,weekly,monthly} jobs, and then exits. If there are no
overdue jobs, anacron exits immediately.

BTW, don't try to apply this knowledge to more recent releases, such
as Fedora 12. There, the interaction between cron and anacron is
more complex. The standard setup there is for cron to run only the
hourly jobs and for anacron, started each hour as one of those jobs,
to run any needed {daily,weekly,monthly} jobs.

--
Bob Nichols "NOSPAM" is really part of my email address.
Do NOT delete it.

_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 

Thread Tools




All times are GMT. The time now is 12:26 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org