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 > Redhat > Fedora User

 
 
LinkBack Thread Tools
 
Old 03-01-2010, 02:56 PM
Timothy Murphy
 
Default Mystified by crontab/anacrontab

I'm trying to understand how cron works nowadays.
I've been comparing my Fedora-12 laptop
with my CentOS-5.4 desktop,
and am slightly baffled by the difference between them.

On the Fedora-12 system the venerable /etc/crontab is empty,
and the work to be done is listed in /etc/anacrontab .
As far as I can make out, there is a program /etc/cron.d/0hourly
which every hour runs /etc/cron.hourly,
which in turn runs a program 0anacron,
which presumably checks /etc/anacron.daily, etc.

I take it this roundabout process is intended
to deal with the case where a laptop is only running
for part of the time?

In any case, the system seems to work well enough.
The programs that run are listed in /var/log/cron .

On my CentOS desktop, both /etc/crontab and /etc/anacrontab
list cron.daily, cron.weekly and cron.monthly ,
and crontab also lists cron.hourly .
But I see nothing in /etc/cron.d to run anacron ,
so it is not clear to me if /etc/anacrontab plays any role.

Also I get no messages in /var/log/cron to say
what individual programs are run hourly, daily, etc.
I'm just told eg
---------------------------------------
Jan 31 04:22:01 helen crond[27497]:
(root) CMD (run-parts /etc/cron.weekly)
Jan 31 04:22:01 helen anacron[27501]:
Updated timestamp for job `cron.weekly' to 2010-01-31
---------------------------------------
Since the second message is from anacron,
I assume that crond has started anacron running,
although if that is so it is not mentioned in "man crond".

Also the individual scripts/programs that are run
are not listed in /var/log/cron ,
although I think that may just be an oddity or omission
on the part of CentOS, which does not run "logger" in run-parts
as Fedora does

I see that /usr/bin/run-parts does include
---------------------------------------
$i 2>&1 | awk -v "progname=$i"
'progname {
print progname ":
"
progname="";
}
{ print; }'
---------------------------------------
but I'm not sure what happens to material like this
which would appear on the screen if the program were run directly?

Any enlightenment gratefully received.

--
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

--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
 
Old 03-01-2010, 03:55 PM
Tom Horsley
 
Default Mystified by crontab/anacrontab

On Mon, 01 Mar 2010 15:56:03 +0000
Timothy Murphy wrote:

> Any enlightenment gratefully received.

I don't know about enlightenment, but I find the whole anacron
thing absolutely useless and annoying. I used to be able
to get rid of it by disabling the (separate) anacron
service, or "yum erase anacron", but now that isn't
possible. Instead I have to go to alot of trouble to
transfer the anacrontab entries to crontab (fixing the
format) and eradicate everything anacron does by squashing
several files. I've got this script which runs in
a yum hook I wrote after every update to make sure
it stays squashed:

#!/bin/bash
#
# Drive a stake through anacron's heart if updates try to
# reinstall it.
#
for i in /etc/cron.d/0hourly /etc/cron.hourly/0anacron /etc/anacrontab
do
if [ -s $i ]
then
cat /dev/null > $i
fi
rm -f $i.rpmnew
rm -f $i.rpmsave
done

Now my cron jobs run when they are supposed to run, not at some
random unpredictable and highly inconvenient time.
--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
 
Old 03-01-2010, 04:07 PM
Robert Nichols
 
Default Mystified by crontab/anacrontab

On 03/01/2010 09:56 AM, Timothy Murphy wrote:
> I'm trying to understand how cron works nowadays.
> I've been comparing my Fedora-12 laptop
> with my CentOS-5.4 desktop,
> and am slightly baffled by the difference between them.
>
> On the Fedora-12 system the venerable /etc/crontab is empty,
> and the work to be done is listed in /etc/anacrontab .
> As far as I can make out, there is a program /etc/cron.d/0hourly
> which every hour runs /etc/cron.hourly,
> which in turn runs a program 0anacron,
> which presumably checks /etc/anacron.daily, etc.
>
> I take it this roundabout process is intended
> to deal with the case where a laptop is only running
> for part of the time?
>
> In any case, the system seems to work well enough.
> The programs that run are listed in /var/log/cron .
>
> On my CentOS desktop, both /etc/crontab and /etc/anacrontab
> list cron.daily, cron.weekly and cron.monthly ,
> and crontab also lists cron.hourly .
> But I see nothing in /etc/cron.d to run anacron ,
> so it is not clear to me if /etc/anacrontab plays any role.
>
> Also I get no messages in /var/log/cron to say
> what individual programs are run hourly, daily, etc.
> I'm just told eg
> ---------------------------------------
> Jan 31 04:22:01 helen crond[27497]:
> (root) CMD (run-parts /etc/cron.weekly)
> Jan 31 04:22:01 helen anacron[27501]:
> Updated timestamp for job `cron.weekly' to 2010-01-31
> ---------------------------------------
> Since the second message is from anacron,
> I assume that crond has started anacron running,
> although if that is so it is not mentioned in "man crond".
>
> Also the individual scripts/programs that are run
> are not listed in /var/log/cron ,
> although I think that may just be an oddity or omission
> on the part of CentOS, which does not run "logger" in run-parts
> as Fedora does
>
> I see that /usr/bin/run-parts does include
> ---------------------------------------
> $i 2>&1 | awk -v "progname=$i"
> 'progname {
> print progname ":
"
> progname="";
> }
> { print; }'
> ---------------------------------------
> but I'm not sure what happens to material like this
> which would appear on the screen if the program were run directly?

In CentOS 5, anacron is started by init on entry to any of runlevels
2-5. The anacron process checks /var/spool/anacron to see if there
are any overdue jobs, runs (after a delay) any that are needed, and
then terminates. As long as the system is up, scheduled jobs are
handled by cron via the "run-parts" lines in /etc/crontab. The
"0-anacron" jobs in each of the cron.{hourly,daily,weekly,monthly}
directories do nothing but update the timestamp in /var/spool/anacron
so that the next time you boot (or change runlevels) anacron can
see whether anything needs to be done.

The situation in Fedora 12 is a bit more complex. Once an hour,
as instructed by /etc/cron.d/0hourly, the cron daemon will run all
the jobs in /etc/cron.hourly and the first of those is the
0anacron job that will, if you are running on AC power, start an
anacron process to run any needed {daily,weekly,monthly} job.
It's done that way to provide a centralized place for checking
that the machine is not running on battery and for adding random
delay to the starting of jobs, as some of those might be sending
data to a central server and you don't want all the machines on
your network to do that simultaneously.

Hope that clarifies things.

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

--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
 
Old 03-01-2010, 04:28 PM
Robert Nichols
 
Default Mystified by crontab/anacrontab

On 03/01/2010 10:55 AM, Tom Horsley wrote:
> On Mon, 01 Mar 2010 15:56:03 +0000
> Timothy Murphy wrote:
>
>> Any enlightenment gratefully received.
>
> I don't know about enlightenment, but I find the whole anacron
> thing absolutely useless and annoying. I used to be able
> to get rid of it by disabling the (separate) anacron
> service, or "yum erase anacron", but now that isn't
> possible. Instead I have to go to alot of trouble to
> transfer the anacrontab entries to crontab (fixing the
> format) and eradicate everything anacron does by squashing
> several files. I've got this script which runs in
> a yum hook I wrote after every update to make sure
> it stays squashed:

The best way to disable anacron is to edit /etc/anacrontab and
change the START_HOURS_RANGE to something impossible. I use
"START_HOURS_RANGE=25-25" on my laptop, where I prefer to run
the various daily, weekly, and monthly jobs manually,
generally just before shutting the machine down at the end of
the day. The /etc/anacrontab file is marked as a configuration
file in the RPM, so it is preserved during updates.

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

--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
 
Old 03-01-2010, 05:12 PM
Tom Horsley
 
Default Mystified by crontab/anacrontab

On Mon, 01 Mar 2010 11:28:56 -0600
Robert Nichols wrote:

> The best way to disable anacron is to edit /etc/anacrontab and
> change the START_HOURS_RANGE to something impossible. I use
> "START_HOURS_RANGE=25-25" on my laptop, where I prefer to run
> the various daily, weekly

That's a way, I don't know about the best way. That's the exact
sort of thing someone might decide "Oh! That's impossible, he
couldn't mean that, let's just assume an obviously superior
value for the poor user who mis-configured his anacrontab." :-).
--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
 
Old 03-01-2010, 07:19 PM
Robert Nichols
 
Default Mystified by crontab/anacrontab

On 03/01/2010 12:12 PM, Tom Horsley wrote:
> On Mon, 01 Mar 2010 11:28:56 -0600
> Robert Nichols wrote:
>
>> The best way to disable anacron is to edit /etc/anacrontab and
>> change the START_HOURS_RANGE to something impossible. I use
>> "START_HOURS_RANGE=25-25" on my laptop, where I prefer to run
>> the various daily, weekly
>
> That's a way, I don't know about the best way. That's the exact
> sort of thing someone might decide "Oh! That's impossible, he
> couldn't mean that, let's just assume an obviously superior
> value for the poor user who mis-configured his anacrontab." :-).

I confess that I peeked at the source before doing that.

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

--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
 
Old 03-01-2010, 09:32 PM
Timothy Murphy
 
Default Mystified by crontab/anacrontab

Robert Nichols wrote:

>> I'm trying to understand how cron works nowadays.
>> I've been comparing my Fedora-12 laptop
>> with my CentOS-5.4 desktop,
>> and am slightly baffled by the difference between them.

> In CentOS 5, anacron is started by init on entry to any of runlevels
> 2-5. The anacron process checks /var/spool/anacron to see if there
> are any overdue jobs, runs (after a delay) any that are needed, and
> then terminates. As long as the system is up, scheduled jobs are
> handled by cron via the "run-parts" lines in /etc/crontab. The
> "0-anacron" jobs in each of the cron.{hourly,daily,weekly,monthly}
> directories do nothing but update the timestamp in /var/spool/anacron
> so that the next time you boot (or change runlevels) anacron can
> see whether anything needs to be done.
>
> The situation in Fedora 12 is a bit more complex. Once an hour,
> as instructed by /etc/cron.d/0hourly, the cron daemon will run all
> the jobs in /etc/cron.hourly and the first of those is the
> 0anacron job that will, if you are running on AC power, start an
> anacron process to run any needed {daily,weekly,monthly} job.
> It's done that way to provide a centralized place for checking
> that the machine is not running on battery and for adding random
> delay to the starting of jobs, as some of those might be sending
> data to a central server and you don't want all the machines on
> your network to do that simultaneously.
>
> Hope that clarifies things.

Yes, thanks.
I've added the two "logger" lines from Fedora run-parts to CentOS:
----------------------------------------
logger -p cron.notice -t "run-parts($1)[$$]" "starting $(basename
$i)"
if [ -x $i ]; then
$i 2>&1 | awk -v "progname=$i"
'progname {
print progname ":
"
progname="";
}
{ print; }'
logger -i -p cron.notice -t "run-parts($1)" "finished $(basename
$i)"
----------------------------------------
Now all cron actions are recorded in /var/log/cron ,
both those in /etc/cron.d/ and those in /etc/cron.hourly, etc,
which seems more logical to me.


--
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

--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
 

Thread Tools




All times are GMT. The time now is 09:29 PM.

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