Re: Best practices for cron jobs?

2007-06-14 Thread Mark Brown
On Wed, Jun 13, 2007 at 08:46:42PM +0200, sean finney wrote:
 On Wednesday 13 June 2007 06:28:09 Duncan Findlay wrote:

  I imagine it would be relatively simple to have the postinst generate
  a random time during the day for a cron script to run, but this
  doesn't work with anacron -- many users would never get updates.

 how would this break anacron?

If you're not using cron.{daily,weekly,whatever} then if the system is
not running at the time the job is due to go off it will not be run by
anacron when the system is next started.

-- 
You grabbed my hand and we fell into it, like a daydream - or a fever.


signature.asc
Description: Digital signature


Re: Best practices for cron jobs?

2007-06-13 Thread Bas Zoetekouw
Hi Duncan!

You wrote:

 Adding a sleep $[ $RANDOM % 60 ] is probably not a good idea as it will
 hold up all the other cronjobs that should be run.

What about making sure the spamassassin cron.daily job is the last one
to run (by calling it ZZspamassassin or so)?  It might even be worth it
to put the random wait in its own /etc/cron.daily/ZZ_randomwait, so that
other packages could also benefit from the same construction.

Regards,
Bas.
-- 
+--+
| Bas Zoetekouw  | Sweet day, so cool, so calm, so bright, |
|| The bridall of the earth and skie:  |
| [EMAIL PROTECTED]  | The dew shall weep thy fall tonight;|
+|For thou must die.   |
 +-+


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: Best practices for cron jobs?

2007-06-13 Thread Gabor Gombas
On Wed, Jun 13, 2007 at 12:28:09AM -0400, Duncan Findlay wrote:

 What can I do to satisfy those with and without anacron, and to avoid
 hammering the sa-update servers at a specific time?

Idea:

- Generate a random minute number in the postinst
- Set up an entry in cron.d that runs every hour at the above specified
  minute and calls a helper script that checks if the last invocation of
  sa-update was more than 23 hours ago (using a timestamp file) and if
  so calls sa-update

Gabor

-- 
 -
 MTA SZTAKI Computer and Automation Research Institute
Hungarian Academy of Sciences
 -



Re: Best practices for cron jobs?

2007-06-13 Thread sean finney
On Wednesday 13 June 2007 06:28:09 Duncan Findlay wrote:
 I imagine it would be relatively simple to have the postinst generate
 a random time during the day for a cron script to run, but this
 doesn't work with anacron -- many users would never get updates.

how would this break anacron?

 What can I do to satisfy those with and without anacron, and to avoid
 hammering the sa-update servers at a specific time?

personally, i would do something like this:

  - generate the crontab with a random hour/minute into a temp file
  - register the temp file /etc/cron.d/yourpackage via ucf


sean


signature.asc
Description: This is a digitally signed message part.


Re: Best practices for cron jobs?

2007-06-13 Thread Adeodato Simó
* sean finney [Wed, 13 Jun 2007 20:46:42 +0200]:

 On Wednesday 13 June 2007 06:28:09 Duncan Findlay wrote:
  I imagine it would be relatively simple to have the postinst generate
  a random time during the day for a cron script to run, but this
  doesn't work with anacron -- many users would never get updates.

 how would this break anacron?

Because anacron can't run stuff only present in /etc/cron.d.

Cheers,

-- 
Adeodato Simó dato at net.com.org.es
Debian Developer  adeodato at debian.org
 
As scarce as truth is, the supply has always been in excess of the demand.
-- Josh Billings


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: Best practices for cron jobs?

2007-06-13 Thread Jan-Pascal van Best
Duncan Findlay wrote:
 Adding a sleep $[ $RANDOM % 60 ] is probably not a good idea as it will
 hold up all the other cronjobs that should be run.
   
How about using a sub shell, so that other cron jobs can continue?
(
sleep $[ $RANDOM % 60 ]
sa-update
) 

(or something like this)

Cheers

Jan-Pascal




signature.asc
Description: OpenPGP digital signature


Re: Best practices for cron jobs?

2007-06-13 Thread Florian Weimer
* Duncan Findlay:

 I imagine it would be relatively simple to have the postinst generate
 a random time during the day for a cron script to run, but this
 doesn't work with anacron -- many users would never get updates.

debsecan creates a cron entry which is run hourly, at a random minute,
and the invoked script simply does nothing unless a day has passed
since the last activity.

This was the best thing I could come up with.  People keep talking
about ucf in this context, but I don't see how it contributes to a
solution. (Just make sure that the generated cron entry does not
contain any configuration data such as command line arguments.)


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: Best practices for cron jobs?

2007-06-13 Thread Brian May
 Duncan == Duncan Findlay [EMAIL PROTECTED] writes:

Duncan What can I do to satisfy those with and without anacron,
Duncan and to avoid hammering the sa-update servers at a specific
Duncan time?

Look at the clamav-freshclam package.

I suspect the maintainers have already encountered similar issues to
yours.

I can't remember the details of how clamav-freshclam works right now
though.
-- 
Brian May [EMAIL PROTECTED]


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Best practices for cron jobs?

2007-06-12 Thread Duncan Findlay
Hi everybody,

What is the best practice when it comes to packages that need to
access a network resource in a daily cronjob? Specifically I'd like to
have a daily cronjob included in the spamassassin package that will
run sa-update. I planned to do this by dropping a con job in
cron.daily. As was pointed out in bug 428319, this results in many
servers hitting the spamassassin update servers at 6:25 am local time
(every server in a timezone that does not have anacron
installed). Ideally this should be spread out throughout the course of
an hour (at least).

Adding a sleep $[ $RANDOM % 60 ] is probably not a good idea as it will
hold up all the other cronjobs that should be run.

I imagine it would be relatively simple to have the postinst generate
a random time during the day for a cron script to run, but this
doesn't work with anacron -- many users would never get updates.

What can I do to satisfy those with and without anacron, and to avoid
hammering the sa-update servers at a specific time?

Thanks!
-- 
Duncan Findlay


pgpqxfJCSucpx.pgp
Description: PGP signature