cl->cl_timefreq = (time_t) bufi;
break;
+ case S_JITTER_T:
+ /* read the jitter (uchar) to use to set next execution time */
+ Read(bufi, size, "Error while reading jitter field");
+ cl->cl_jitter = (unsigned char) bufi;
+ break;
+
case S_MINS_T:
Read(cl->cl_mins, size, "Error while reading mins field");
break;
nextexe += ( (i= int_end_timet - nextexe) > 0) ?
(time_t)(((float)i * (float)rand())/(float)RAND_MAX) : 0;
}
+ else if (is_td(line->cl_option) && line->cl_runfreq != 1 && line->cl_jitter > 0){
+ /* &-lines only:
+ * run the command between nextexe and nextexe+jitter seconds,
+ * as a way not to have 100 jobs all starting exactly at
+ * the second 0 of the minute they should run */
+ nextexe += (time_t)(((float)line->cl_jitter * (float)rand())/(float)RAND_MAX);
+ }
line->cl_nextexe = nextexe + (line->cl_file->cf_tzdiff * 3600);
</listitem>
</varlistentry>
+ <varlistentry id="fcrontab.5.jitter">
+ <term>jitter</term>
+ <listitem>
+ <para><emphasis><type>integer</type></emphasis>(<constant>0</constant>)</para>
+ <para>Run the task between 0 and jitter seconds later than it should have been run. This options only applies to &-lines and is intended for systems where many jobs are supposed to be started at the same minute: the jitter option will randomly spread the start of all those jobs across the first jitter seconds of the minute instead of starting all of them at the first second of the minute. The argument must be between 0 and 255 (inclusive).</para>
+ <para>&seealso; option &optrandom;.</para>
+ </listitem>
+ </varlistentry>
+
<varlistentry id="fcrontab.5.lavg">
<term>lavg</term>
<listitem>
easy to guess for skilled people: thus, you shouldn't rely on this option
to make important things secure. However, it shouldn't be a problem
for most uses.</para>
+ <para>&seealso; option &optjitter;.</para>
</listitem>
</varlistentry>
<!ENTITY optexesev '<link linkend="fcrontab.5.exesev"><varname>exesev</varname></link>'>
<!ENTITY optfirst '<link linkend="fcrontab.5.first"><varname>first</varname></link>'>
<!ENTITY optforcemail '<link linkend="fcrontab.5.forcemail"><varname>forcemail</varname></link>'>
+<!ENTITY optjitter '<link linkend="fcrontab.5.jitter"><varname>jitter</varname></link>'>
<!ENTITY optlavg '<link linkend="fcrontab.5.lavg"><varname>lavg</varname></link>'>
<!ENTITY optlavg1 '<link linkend="fcrontab.5.lavgX"><varname>lavg1</varname></link>'>
<!ENTITY optlavg5 '<link linkend="fcrontab.5.lavgX"><varname>lavg5</varname></link>'>
fprintf(stderr, " Opt : \"%s\" %d\n", opt_name, i);
}
+ else if( strcmp(opt_name, "jitter") == 0 ) {
+ if(!in_brackets ||(ptr=get_num(ptr, &i, UCHAR_MAX, 0, NULL))==NULL)
+ Handle_err;
+ cl->cl_jitter = i;
+ if (debug_opt)
+ fprintf(stderr, " Opt : \"%s\" %d\n", opt_name, i);
+ }
+
/* handle %-line : we check if we are really in a %-line (which we do not do
* for other options), because writing "&hourly" in a fcrontab results in an
* error (hourly ignored) hard to find, and, in any case, annoying. */
unsigned char cl_lavg[LAVG_SIZE];/*load averages needed (1,5,15 mins) */
unsigned char cl_numexe; /* entries in queues & running processes */
char cl_nice; /* nice value to control priority */
+ unsigned char cl_jitter; /* run randomly late up to jitter seconds */
/* see bitstring(3) man page for more details */
bitstr_t bit_decl(cl_mins, 60); /* 0-59 */
bitstr_t bit_decl(cl_hrs, 24); /* 0-23 */
if ( line->cl_tz != NULL ) {
Save_str(fd, S_TZ_T, line->cl_tz, write_buf, &write_buf_used);
}
+ if ( line->cl_jitter > 0 ) {
+ Save_lint(fd, S_JITTER_T, line->cl_jitter, write_buf, &write_buf_used);
+ }
if ( is_freq(line->cl_option) ) {
/* save the frequency to run the line */
#define S_OPTION_T 2017 /* options for that line (see option.h) */
#define S_FIRST_T 2018 /* wait time before first execution */
#define S_TZ_T 2019 /* time zone of the line */
+#define S_JITTER_T 2020 /* jitter of the line */
#endif /* __SAVE_H__ */