confd: schedule: start crond only when a schedule is active

crond shipped auto-enabled in finit (symlinked into enabled/), so it ran
on every boot.  With no cron jobs /var/spool/cron/crontabs does not exist
and 'crond -f' exits non-zero, which finit then crash-loops until it gives
up ("Service crond keeps crashing, not restarting").

Ship crond available-only and let confd manage it: the schedule plugin
already rebuilds the crontab on every change, so enable + touch crond when
at least one consumer is active and disable it otherwise.  No jobs, no
crond, no crash loop.

Signed-off-by: Mattias Walström <lazzer@gmail.com>
This commit is contained in:
Mattias Walström
2026-06-26 13:33:44 +02:00
parent d194b52629
commit 7030f85484
2 changed files with 9 additions and 5 deletions
+2
View File
@@ -38,6 +38,8 @@ endif
define CONFD_INSTALL_EXTRA
for fn in confd.conf crond.conf resolvconf.conf; do \
cp $(CONFD_PKGDIR)/$$fn $(FINIT_D)/available/; \
done
for fn in confd.conf resolvconf.conf; do \
ln -sf ../available/$$fn $(FINIT_D)/enabled/$$fn; \
done
cp $(CONFD_PKGDIR)/tmpfiles.conf $(TARGET_DIR)/etc/tmpfiles.d/confd.conf
+7 -5
View File
@@ -176,11 +176,13 @@ done:
snprintf(expr, sz, "%s %s %s %s %s", min, hr, dom, mon, dow);
}
static void reload_crond(void)
static void crond_apply(int active)
{
char *args[] = { "pkill", "-HUP", "crond", NULL };
runbg(args, 0);
if (active) {
finit_enable("crond");
} else {
finit_disable("crond");
}
}
/*
@@ -267,7 +269,7 @@ static void apply_schedules(struct lyd_node *config)
out:
fclose(fp);
reload_crond();
crond_apply(count > 0);
NOTE("schedule: %d active job(s) written to crontab", count);
}