[26724] in Source-Commits
Re: /svn/athena r25710 - trunk/athena/bin/desync
daemon@ATHENA.MIT.EDU (Jonathon Weiss)
Tue Aug 7 20:05:36 2012
Message-Id: <201208080005.q7805WS6013676@outgoing.mit.edu>
To: Jonathan D Reed <jdreed@MIT.EDU>
cc: source-commits@MIT.EDU
In-reply-to: <201208072357.q77Nv6lK001807@drugstore.mit.edu>
Date: Tue, 07 Aug 2012 20:05:32 -0400
From: Jonathon Weiss <jweiss@MIT.EDU>
yay
--
Jonathon
> Author: jdreed
> Date: 2012-08-07 19:57:06 -0400 (Tue, 07 Aug 2012)
> New Revision: 25710
>
> Modified:
> trunk/athena/bin/desync/desync.1
> trunk/athena/bin/desync/desync.c
> Log:
> Update usage and enforce limits in crontab mode
>
> Modified: trunk/athena/bin/desync/desync.1
> ===================================================================
> --- trunk/athena/bin/desync/desync.1 2012-08-07 19:58:58 UTC (rev 25709)
> +++ trunk/athena/bin/desync/desync.1 2012-08-07 23:57:06 UTC (rev 25710)
> @@ -24,7 +24,7 @@
> timefile ] [ range ]
>
> .B desync -c
> -hours [ range ] [ other arguments ]
> +hours [ range [ other arguments ] ]
> .SH DESCRIPTION
> .I desync
> is a tool which sleeps a random (hostname seeded) period of time (up
> @@ -44,7 +44,8 @@
> .TP 8
> .B range
> This optional range specifies, in seconds, the maximum value for the
> -randomly selected sleep time. The default value is 3600.
> +randomly selected sleep time. The default value is 3600 (except in
> +"crontab" mode, see below).
> .TP 8
> .B \-h name
> Use
> @@ -106,16 +107,20 @@
> .B \-c hours
> This option changes the behavior of
> .I desync
> -and causes it to generate output suitable for use in a crontab file.
> -This is useful on modern Linux distributions, where sleeping for
> -extended periods inside a cron job can confuse power management software
> -or packages such as ConsoleKit, and running a cron job every 5 minutes
> -to see if desync thinks it is "time to run" is undesirable. Since
> -desync will generate the same value each time on the same machine, it is
> -fine to generate crontab files in a package's post-install script, for
> -example. In this mode, desync will output the crontab fields and then
> -any additional arguments you supply. So to generate a crontab with a
> -randomized job, one might do something like this:
> +and causes it to generate output suitable for use in a crontab file. It
> +also changes the units of
> +.I range
> +to minutes (from seconds), changes the default value to 60 and enforces
> +a maximum value of 1439. This is useful on modern Linux distributions,
> +where sleeping for extended periods inside a cron job can confuse power
> +management software or packages such as ConsoleKit, and running a cron
> +job every 5 minutes to see if desync thinks it is "time to run" is
> +undesirable. Since desync will generate the same value each time on the
> +same machine, it is fine to generate crontab files in a package's
> +post-install script, for example. In this mode, desync will output the
> +crontab fields and then any additional arguments you supply. So to
> +generate a crontab with a randomized job, one might do something like
> +this:
>
> .nf
> for i in 2 4 8 14 20; do
>
> Modified: trunk/athena/bin/desync/desync.c
> ===================================================================
> --- trunk/athena/bin/desync/desync.c 2012-08-07 19:58:58 UTC (rev 25709)
> +++ trunk/athena/bin/desync/desync.c 2012-08-07 23:57:06 UTC (rev 25710)
> @@ -95,9 +95,10 @@
> argc -= 1;
> argv += 1;
> } else {
> - range = 3600;
> + range = crontabhour == NULL ? 3600 : 60;
> }
> - if (range == 0)
> + if ((range == 0) ||
> + (crontabhour && (range >= 1440)))
> {
> fprintf(stderr, "%s: Invalid range value\n", progname);
> usage();
> @@ -234,6 +235,6 @@
> static void usage()
> {
> fprintf(stderr,
> - "Usage: %s [-h name] [-n] [-t timefile] [range]\n %s -c hour [range] [crontab arguments]\n",
> + "Usage: %s [-h name] [-n] [-t timefile] [range]\n %s -c hour [range [crontab arguments]]\n",
> progname, progname);
> }
>