[15156] | 1 | .\" $Id: desync.8,v 1.3 2000-09-30 21:08:29 rbasch Exp $ |
---|
[9726] | 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 | .\" |
---|
[25696] | 17 | .TH DESYNC 1 "3 August 2012" |
---|
[9726] | 18 | .SH NAME |
---|
| 19 | desync \- desynchronize timed jobs on networks |
---|
| 20 | .SH SYNOPSIS |
---|
| 21 | .B desync |
---|
| 22 | [ |
---|
| 23 | .B \-t |
---|
| 24 | timefile ] [ range ] |
---|
[25696] | 25 | |
---|
[25704] | 26 | .B desync -c |
---|
[25710] | 27 | hours [ range [ other arguments ] ] |
---|
[9726] | 28 | .SH DESCRIPTION |
---|
| 29 | .I desync |
---|
[15136] | 30 | is a tool which sleeps a random (hostname seeded) period of time (up |
---|
[9726] | 31 | to an hour, by default) in order to skew the network load from several |
---|
| 32 | machines running |
---|
| 33 | .I cron |
---|
| 34 | jobs that would otherwise be synchronized. |
---|
| 35 | |
---|
| 36 | An invocation would appear something like |
---|
| 37 | |
---|
| 38 | .nf |
---|
| 39 | 42 * * * * desync; /usr/lib/sendmail -q |
---|
| 40 | .fi |
---|
| 41 | |
---|
| 42 | in a crontab file. |
---|
| 43 | .SH OPTIONS |
---|
| 44 | .TP 8 |
---|
| 45 | .B range |
---|
| 46 | This optional range specifies, in seconds, the maximum value for the |
---|
[25710] | 47 | randomly selected sleep time. The default value is 3600 (except in |
---|
| 48 | "crontab" mode, see below). |
---|
[9726] | 49 | .TP 8 |
---|
[15156] | 50 | .B \-h name |
---|
| 51 | Use |
---|
| 52 | .I name |
---|
| 53 | to seed the random number generator, instead of using the current host |
---|
| 54 | name. This option is generally only useful in conjunction with the |
---|
| 55 | .B \-n |
---|
| 56 | option. |
---|
| 57 | .TP 8 |
---|
| 58 | .B \-n |
---|
| 59 | Instead of sleeping, this option causes |
---|
| 60 | .I desync |
---|
| 61 | to write the number of seconds it would sleep to standard output, or, |
---|
| 62 | if the |
---|
| 63 | .B \-t |
---|
| 64 | option is also specified, the number of seconds remaining until the |
---|
| 65 | timer in |
---|
| 66 | .I timefile |
---|
| 67 | expires. |
---|
| 68 | .TP 8 |
---|
[9726] | 69 | .B \-t timefile |
---|
| 70 | This option changes the behavior of |
---|
| 71 | .I desync |
---|
| 72 | to make it useful for desynchronizing jobs when sleeping is not |
---|
| 73 | appropriate. If |
---|
| 74 | .I timefile |
---|
| 75 | does not exist, |
---|
| 76 | .I desync |
---|
| 77 | selects a random sleep time using the normal method, adds it to the |
---|
| 78 | current time value, writes the result into |
---|
| 79 | .IR timefile , |
---|
| 80 | and exits with status 1. If |
---|
| 81 | .I timefile |
---|
| 82 | does exist and the current time is less than the time value listed in |
---|
| 83 | .IR timefile , |
---|
| 84 | then |
---|
| 85 | .I desync |
---|
| 86 | takes no action and exits with status 1. If |
---|
| 87 | .I timefile |
---|
| 88 | exists and the current time is equal to or greater than the time value |
---|
| 89 | listed in |
---|
[25706] | 90 | .IR timefile , |
---|
[9726] | 91 | then |
---|
| 92 | .I desync |
---|
| 93 | unlinks |
---|
| 94 | .I timefile |
---|
| 95 | and exits with status 0. This feature can be used in shell code of |
---|
| 96 | the 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 | |
---|
[25696] | 106 | .TP 8 |
---|
| 107 | .B \-c hours |
---|
| 108 | This option changes the behavior of |
---|
| 109 | .I desync |
---|
[25710] | 110 | and causes it to generate output suitable for use in a crontab file. It |
---|
| 111 | also changes the units of |
---|
| 112 | .I range |
---|
| 113 | to minutes (from seconds), changes the default value to 60 and enforces |
---|
| 114 | a maximum value of 1439. This is useful on modern Linux distributions, |
---|
| 115 | where sleeping for extended periods inside a cron job can confuse power |
---|
| 116 | management software or packages such as ConsoleKit, and running a cron |
---|
| 117 | job every 5 minutes to see if desync thinks it is "time to run" is |
---|
| 118 | undesirable. Since desync will generate the same value each time on the |
---|
| 119 | same machine, it is fine to generate crontab files in a package's |
---|
| 120 | post-install script, for example. In this mode, desync will output the |
---|
| 121 | crontab fields and then any additional arguments you supply. So to |
---|
| 122 | generate a crontab with a randomized job, one might do something like |
---|
| 123 | this: |
---|
[25696] | 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 | |
---|
[9726] | 132 | .SH SEE ALSO |
---|
[23137] | 133 | cron(8) |
---|
[9726] | 134 | .SH AUTHOR |
---|
| 135 | Craig Fields, MIT Information Systems |
---|
| 136 | .br |
---|
| 137 | Greg Hudson, MIT Information Systems |
---|
| 138 | .br |
---|
[25696] | 139 | Debathena Project |
---|
| 140 | .br |
---|
| 141 | Copyright (c) 1995, 1996, 1997, 2012 Massachusetts Institute of Technology |
---|