scron

simple cron daemon
git clone git://git.2f30.org/scron
Log | Files | Refs | README | LICENSE

commit dc949dc6260284733c85f8a22e693fe9f77e2135
parent 4200147d3f84918326677433b241e101e58c4ffc
Author: sin <sin@2f30.org>
Date:   Sun,  6 Jul 2014 14:28:52 +0100

Warn the user when discarding old crontab entries

Upon reloading the daemon, if the new config file has syntax errors,
crond will discard the previously loaded crontab entries.

Diffstat:
Mcrond.c | 16+++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/crond.c b/crond.c @@ -57,6 +57,17 @@ loginfo(const char *fmt, ...) } static void +logwarn(const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + if (dflag == 1) + vsyslog(LOG_WARNING, fmt, ap); + vfprintf(stderr, fmt, ap); + va_end(ap); +} + +static void logerr(const char *fmt, ...) { va_list ap; @@ -320,8 +331,11 @@ loadentries(void) TAILQ_INSERT_TAIL(&ctabhead, cte, entry); } - if (r < 0) + if (r < 0) { + if (reload == 1) + logwarn("warning: discarding old crontab entries\n"); unloadentries(); + } free(line); fclose(fp);