[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: What does 'apt' in /etc/cron.daily do?



Harry Putnam wrote:
> Further testing... first take anacron out of play as BobP suggests.
> I removed the the anacron part of the line in /etc/crontab 
> original(except dates) :

Just for the record I was suggesting:

  apt-get remove anacron

That by itself should be sufficient.  And then if you desired to have
it back you could:

  apt-get install anacron

And it would all be as it was before.  Either way.  In or out.

>    47 22  * * *	 root	test -x /usr/sbin/anacron || 
>         ( cd / && run-parts --report /etc/cron.daily
> 
> edited:
> 
>   47 22  * * *	root   cd / && run-parts --report /etc/cron.daily

Let me comment on the idiom.  In Debian we want things to be as
automatic as possible.  The /etc/crontab file is owned by 'cron'.  But
it is nice if users can install 'anacron' and have it work without
needing to do anything.

A long time traditional cron idiom is to test for something and then
do something depending upon the test being true or false.  Sometimes
that is if $HOME is mounted.  That way if /home is not mounted such as
during some maintenance then cron won't make a lot of noise.

  test -d $HOME && dosomething

Sometimes the test will be as above with anacron.  If the anacron
program is installed then do nothing because anacron will do it.  But
if anacron is not installed then do it ourselves.

  test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )

As can be seen by this logic it means that no configuration changes
are needed if anacron is installed or removed or never installed or
re-installed or whatever.  It doesn't scale very well because cron
needs to know about anacron.  But for a single special case like this
it works pretty well.

And so if anacron is apt-get removed then /usr/sbin/anacron does not
exist and run-parts will be run.  It isn't necessary to edit the line
if the anacron package is removed.

> And then adjusted the time to be able to watch the test.

Sure!  I do that all of the time when I am testing.  Put it a minute
in the future and wait for it to run.

> Although there is a hefty pause for the `apt' script, it finishes and
> logs are rotated, not what I thought was happening.

It would still be interesting to know why apt is taking so long.  Is
it taking a long time due to the random sleep?  What does this say for
you?  For me there is no output and the sleep is not configured.

  apt-config shell FOO APT::Periodic::RandomSleep

> So it seems to indicate that anacron is the problem.... but no,
> there's more.
> 
> Then I switched the /etc/crontab line again so that anacron was the
> only thing on it.  And, well, once again hefty pause for `apt' script
> but logs are rotated.
> 
> OK, so my problem is solved.... I have no idea what I did to `fix' it,
> but it was totally accidental whatever it was.

Perhaps restarting cron happened?  Perhaps causing cron to re-read the
crontab was enough to reset cron?  Since it almost seems that cron was
not running previously.

> Rotation is apparently working as it should.

Yay.  Good.

Bob

Attachment: signature.asc
Description: Digital signature


Reply to: