From 7030f85484de891ed9e7188eb688f4ac38f0bff0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20Walstr=C3=B6m?= Date: Fri, 26 Jun 2026 10:21:38 +0200 Subject: [PATCH] confd: schedule: start crond only when a schedule is active MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- package/confd/confd.mk | 2 ++ src/confd/src/schedule.c | 12 +++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/package/confd/confd.mk b/package/confd/confd.mk index 4ec5b577..164f1591 100644 --- a/package/confd/confd.mk +++ b/package/confd/confd.mk @@ -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 diff --git a/src/confd/src/schedule.c b/src/confd/src/schedule.c index 1a67d43b..76eb1365 100644 --- a/src/confd/src/schedule.c +++ b/src/confd/src/schedule.c @@ -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); }