}
if (context == CONTEXT_BOOT
- || (context == CONTEXT_DEFAULT && is_volatile(cl->cl_option))) {
+ || (context == CONTEXT_DEFAULT && is_volatile(cl->cl_option))
+ || (context == CONTEXT_RESUME && is_runatresume(cl->cl_option))) {
clear_hasrun(cl->cl_option);
}
else if (is_td(cl->cl_option)) {
/* set the time and date of the next execution */
- if (context == CONTEXT_BOOT && is_runatreboot(cl->cl_option)) {
+ if ((context == CONTEXT_BOOT && is_runatreboot(cl->cl_option))
+ || (context == CONTEXT_RESUME && is_runatresume(cl->cl_option))) {
if (is_notice_notrun(cl->cl_option)) {
}
/* standard @-lines */
- if (context == CONTEXT_BOOT && is_runatreboot(cl->cl_option)) {
+ if ((context == CONTEXT_BOOT && is_runatreboot(cl->cl_option))
+ || (context == CONTEXT_RESUME && is_runatresume(cl->cl_option))) {
cl->cl_nextexe = now;
}
else if (is_new_file || is_volatile(cl->cl_option)
#define LAVG 1 /* set_next_exe_notrun() : context */
#define SYSDOWN 2 /* set_next_exe_notrun() : context */
#define QUEUE_FULL 3 /* set_next_exe_notrun() : context */
-#define SYSDOWN_RUNATREBOOT 4 /* set_next_exe_notrun() : context */
+#define SYSDOWN_RUNATREBOOT 4 /* set_next_exe_notrun() : context - runatreboot or runatresume */
extern void set_next_exe_startup(struct cl_t *cl, const int context,
const time_t sleep_duration);
#define CONTEXT_DEFAULT 1 /* a new file was loaded (and the machine didn't just boot) */
<para>Refactored the socket (for fcrondyn), suspend and select code.</para>
</listitem>
<listitem>
+ <para>Added a new option 'runatresume' (as well as a Vixie-cron-style '@resume' shortcut), to run a job when the system resumes from suspend/hibernation.</para>
+ </listitem>
+ <listitem>
<para>The installation script now supports systemd fully.</para>
</listitem>
</itemizedlist>
</question>
<answer>
<para>fcron now fully supports suspend (to memory or disk).
- On resume it will adjust the task schedules accordingly, run runatreboot tasks if appropriate, and report non-execution of noticenotrun tasks.</para>
+ On resume it will adjust the task schedules accordingly, run runatresume tasks if any, and report non-execution of noticenotrun tasks.</para>
<para>fcron will try to notice suspends by itself without external help.
On Linux it can do so reliably via system APIs, but on other OSes it will instead
check if it wakes up later than it expected after a sleep.
linkend="uptent">lines based on elapsed system up time</link> is recommended instead.</para>
<para>A task using a Vixie cron shortcut is of the form:</para>
<programlisting>shortcut command</programlisting>
- <para>Below is a list of available shortcuts with their fcron equivalent:</para>
+ <para>Below is a list of available shortcuts, plus some fcron-specific additions, with their fcron equivalent:</para>
<table>
<title>Vixie cron shortcuts </title>
<tgroup cols="2">
<entry>@runatreboot,runonce(true)</entry>
<entry> </entry>
</row>
+ <row>
+ <entry>@resume </entry>
+ <entry>Run once, at resume from suspend/hibernate </entry>
+ <entry>@runatresume,runonce(true)</entry>
+ <entry> </entry>
+ </row>
<row>
<entry>@yearly </entry>
<entry>Run once a year </entry>
<listitem>
<para>Option to compile and install from git sources without generating the doc</para>
</listitem>
- <listitem>
- <para>split bootrun into bootrun vs. resumerun, to run when the computer resumes? (similar to bootrun)</para>
- </listitem>
<listitem>
<para>use ask_user() in boot-install</para>
</listitem>
}
+ else if (strcmp(opt_name, "runatresume") == 0) {
+ if (in_brackets && (ptr = get_bool(ptr, &i)) == NULL)
+ Handle_err;
+ if (i == 0)
+ clear_runatresume(cl->cl_option);
+ else
+ set_runatresume(cl->cl_option);
+ if (debug_opt)
+ fprintf(stderr, " Opt : \"%s\" %d\n", opt_name, i);
+ }
+
+
else if (strcmp(opt_name, "runonce") == 0) {
if (in_brackets && (ptr = get_bool(ptr, &i)) == NULL)
Handle_err;
if (debug_opt)
fprintf(stderr, " Shc : @reboot\n");
}
+ if (strcmp(shortcut, "resume") == 0) {
+ set_freq(cl->cl_option);
+ set_runatresume(cl->cl_option);
+ set_runonce(cl->cl_option);
+ clear_volatile(cl->cl_option);
+ cl->cl_runfreq = 0;
+ cl->cl_first = 0;
+ /* the job will not be rescheduled after the first execution (flag is_hasrun),
+ * we set timefreq to LONG_MAX just in case */
+ cl->cl_timefreq = LONG_MAX;
+
+ if (debug_opt)
+ fprintf(stderr, " Shc : @resume\n");
+ }
else if (strcmp(shortcut, "yearly") == 0
|| strcmp(shortcut, "annually") == 0) {
bit_set(cl->cl_mins, 0);
28 runatreboot: if set then run the job at each system startup
29 runonce: if set then run the job only once
30 hasrun: set if the job has been run at least once
+ 31 runatresume: if set then run the job at each system resume (from suspend/hibernation)
*/
(_bit_clear(opt, 24))
/*
- bit 25 : set to 1 : if fcron is running in the forground, then also let jobs print
+ bit 25 : set to 1 : if fcron is running in the foreground, then also let jobs print
to stderr/stdout instead of mailing or discarding it
set to 0 : if fcron is not running in the foreground or this bit is not
set, then treat it as specified with the other options
/*
bit 30 : set to 1 : the job has run at least once since system reboot
- (or since fcron restart if volatile is set)
+ (or since fcron restart if volatile is set,
+ or since last resume if runatresume is set)
set to 0 : job hasn't run yet
*/
#define is_hasrun(opt) \
#define clear_hasrun(opt) \
(_bit_clear(opt, 30))
+/*
+ bit 31 : set to 1 : run the job immediately after the system resume (from suspend/hibernation)
+ set to 0 : leave the nextexe time as it
+*/
+#define is_runatresume(opt) \
+ (_bit_test(opt, 31))
+#define set_runatresume(opt) \
+ (_bit_set(opt, 31))
+#define clear_runatresume(opt) \
+ (_bit_clear(opt, 31))
+
#endif /* __OPTIONH__ */