source: trunk/athena/bin/desync/desync.1 @ 25710

Revision 25710, 3.9 KB checked in by jdreed, 12 years ago (diff)
Update usage and enforce limits in crontab mode
Line 
1.\" $Id: desync.8,v 1.3 2000-09-30 21:08:29 rbasch Exp $
2.\"
3.\" Copyright 1995, 1996, 1997 by the Massachusetts Institute of Technology.
4.\"
5.\" Permission to use, copy, modify, and distribute this
6.\" software and its documentation for any purpose and without
7.\" fee is hereby granted, provided that the above copyright
8.\" notice appear in all copies and that both that copyright
9.\" notice and this permission notice appear in supporting
10.\" documentation, and that the name of M.I.T. not be used in
11.\" advertising or publicity pertaining to distribution of the
12.\" software without specific, written prior permission.
13.\" M.I.T. makes no representations about the suitability of
14.\" this software for any purpose.  It is provided "as is"
15.\" without express or implied warranty.
16.\"
17.TH DESYNC 1 "3 August 2012"
18.SH NAME
19desync \- desynchronize timed jobs on networks
20.SH SYNOPSIS
21.B desync
22[
23.B \-t
24timefile ] [ range ]
25
26.B desync -c
27hours [ range [ other arguments ] ]
28.SH DESCRIPTION
29.I desync
30is a tool which sleeps a random (hostname seeded) period of time (up
31to an hour, by default) in order to skew the network load from several
32machines running
33.I cron
34jobs that would otherwise be synchronized.
35
36An invocation would appear something like
37
38.nf
39     42 * * * *          desync; /usr/lib/sendmail -q
40.fi
41
42in a crontab file.
43.SH OPTIONS
44.TP 8
45.B range
46This optional range specifies, in seconds, the maximum value for the
47randomly selected sleep time.  The default value is 3600 (except in
48"crontab" mode, see below).
49.TP 8
50.B \-h name
51Use
52.I name
53to seed the random number generator, instead of using the current host
54name.  This option is generally only useful in conjunction with the
55.B \-n
56option.
57.TP 8
58.B \-n
59Instead of sleeping, this option causes
60.I desync
61to write the number of seconds it would sleep to standard output, or,
62if the
63.B \-t
64option is also specified, the number of seconds remaining until the
65timer in
66.I timefile
67expires.
68.TP 8
69.B \-t timefile
70This option changes the behavior of
71.I desync
72to make it useful for desynchronizing jobs when sleeping is not
73appropriate.  If
74.I timefile
75does not exist,
76.I desync
77selects a random sleep time using the normal method, adds it to the
78current time value, writes the result into
79.IR timefile ,
80and exits with status 1.  If
81.I timefile
82does exist and the current time is less than the time value listed in
83.IR timefile ,
84then
85.I desync
86takes no action and exits with status 1.  If
87.I timefile
88exists and the current time is equal to or greater than the time value
89listed in
90.IR timefile ,
91then
92.I desync
93unlinks
94.I timefile
95and exits with status 0.  This feature can be used in shell code of
96the following form:
97
98.nf
99        if desync -t /tmp/mytimefile 3600; then
100                echo "Starting the job."
101        else
102                echo "Putting it off until later."
103        fi
104.fi
105
106.TP 8
107.B \-c hours
108This option changes the behavior of
109.I desync
110and causes it to generate output suitable for use in a crontab file.  It
111also changes the units of
112.I range
113to minutes (from seconds), changes the default value to 60 and enforces
114a maximum value of 1439.  This is useful on modern Linux distributions,
115where sleeping for extended periods inside a cron job can confuse power
116management software or packages such as ConsoleKit, and running a cron
117job every 5 minutes to see if desync thinks it is "time to run" is
118undesirable.  Since desync will generate the same value each time on the
119same machine, it is fine to generate crontab files in a package's
120post-install script, for example.  In this mode, desync will output the
121crontab fields and then any additional arguments you supply.  So to
122generate a crontab with a randomized job, one might do something like
123this:
124
125.nf
126        for i in 2 4 8 14 20; do
127            desync -c $i 120 root /etc/athena/update_ws >> /etc/cron.d/update
128        done
129.fi
130
131
132.SH SEE ALSO
133cron(8)
134.SH AUTHOR
135Craig Fields, MIT Information Systems
136.br
137Greg Hudson, MIT Information Systems
138.br
139Debathena Project
140.br
141Copyright (c) 1995, 1996, 1997, 2012 Massachusetts Institute of Technology
Note: See TracBrowser for help on using the repository browser.