These special time specification "nicknames" are supported, which replace
the 5 initial time and date fields, and are prefixed by the '@' character:
.nf
-@reboot : Run once, at startup.
+@reboot : Run once after reboot.
@yearly : Run once a year, ie. "0 0 1 1 *".
@annually : Run once a year, ie. "0 0 1 1 *".
@monthly : Run once a month, ie. "0 0 1 * *".
run_reboot_jobs(cron_db *db) {
user *u;
entry *e;
+ int reboot;
+ pid_t pid = getpid();
+
+ /* lock exist - skip reboot jobs */
+ if (access(REBOOT_LOCK, F_OK)) {
+ log_it("CRON", pid, "INFO", "@reboot jobs will be run at computer's startup.", 0);
+ return;
+ }
+ /* lock doesn't exist - create lock, run reboot jobs */
+ if ((reboot = creat(REBOOT_LOCK, S_IRUSR&S_IWUSR)) < 0)
+ log_it("CRON", pid, "INFO", "Can't create lock for reboot jobs.", errno);
+ else
+ close(reboot);
for (u = db->head; u != NULL; u = u->next) {
for (e = u->crontab; e != NULL; e = e->next) {
# include <paths.h>
#endif /*BSD*/
+#define REBOOT_LOCK "/var/run/cron.reboot"
+
#ifndef CRONDIR
/* CRONDIR is where cron(8) and crontab(1) both chdir
* to; SPOOL_DIR, CRON_ALLOW, CRON_DENY, and LOG_FILE