LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 03-07-2007, 06:12 PM   #1
jtmoon
LQ Newbie
 
Registered: Jun 2006
Location: WA, USA
Distribution: Fedora Core 10
Posts: 15

Rep: Reputation: 5
Question cron file 000-delay.cron (it is on my FC5) - what is the purpose?


I found the file 000-delay.cron.
It introduces a per-machine static sleep before cron jobs.
My guess it that putting a random wait for cron jobs for all *nix machines reduces traffic jams.

For example, what if all machines in a network ran the cron job download-huge-file.cron at the same time? It would cause a big lag for the whole network!

Does anyone else have thoughts on why the file 000-delay.cron exists?

Code:
$ cat /etc/cron.daily/000-delay.cron
#!/bin/bash

# Generate per system static delay for cron.{daily,weekly,monthly}

# (P) & (C) 2006 by Peter Bieringer <pb@bieringer.de>
#
# 20060322/PB: initial release

# License: GPLv2

factor=1        # max. ~ 68 minutes
#factor=2       # max. ~ 34 minutes

# Create md5sum of hostname (static over system lifetime)
md5sum="`echo ${HOSTNAME} | md5sum`"

# Extract the first 3 hexdigits (12 Bit: 0-4095)
hexvalue="${md5sum:0:3}"

# Create decimal value
decvalue="`printf "%d" "0x${hexvalue}"`"

# Divide delay by factor
DELAY=$[ ${decvalue} / ${factor} ]

sleep $DELAY
exit 0


-JTomMoon79

This was also posted here:
http://lists.linuxcoding.com/rhl/2007q1/msg04528.html
 
Old 03-08-2007, 11:15 AM   #2
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 326Reputation: 326Reputation: 326Reputation: 326
It's function is to prevent unintentional denial of service attacks on servers. For example, you have 4000 machines, and daily (in the cron.daily directory) they run ntpdate. Without 000-delay.cron, all 4000 machines would hit the time server at exactly the same time (probably causing it grief, or even killing it).

The 000-delay.cron delay is only introduced at the begining of the sequential execution of all jobs in the cron.daily, cron.weekly and cron.monthly directories.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
shell script using /etc/cron.hourly to execute cron.php file? rioguia Programming 3 06-11-2008 08:09 AM
cron not working from crontab nor form /etc/cron/cron.d. What did SuSE change? JZL240I-U Suse/Novell 11 01-04-2007 01:57 AM
Slackware's Cron Scheduler: I'm thinking maybe I need to put in a different cron? Old_Fogie Slackware 5 11-03-2006 06:25 AM
Can any one plz explain why/what for cron.d, cron.daily, cron.weekly etc are there. mavinashbabu Linux - Newbie 4 09-21-2006 01:50 PM
[cron][mdk9.1]cron deamon seems to ignore some task... yannrichet Linux - Newbie 5 06-26-2003 09:57 AM


All times are GMT -5. The time now is 06:16 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration