scron

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

commit 2d7328ec86dfc0ac30f87565ebde219966fe2616
parent fb1b68d21af265e715b7388bec66bf3cbc816275
Author: Ari Malinen <ari.malinen@gmail.com>
Date:   Tue, 10 Jun 2014 22:08:22 +0300

small fixes

Diffstat:
Adcron | 0
Mdcron.c | 15++++++++-------
2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/dcron b/dcron Binary files differ. diff --git a/dcron.c b/dcron.c @@ -14,7 +14,8 @@ static const char config[] = "/etc/dcron.conf"; FILE *fp; -void inthandler(void) { +void inthandler(int sig) { + puts("quit"); syslog(LOG_NOTICE, "quit"); closelog(); fclose(fp); @@ -39,13 +40,13 @@ int main(int argc, char *argv[]) { } signal(SIGINT, inthandler); - openlog(argv[0], LOG_CONS | LOG_PID, LOG_LOCAL1); syslog(LOG_NOTICE, "start uid:%d", getuid()); while (1) { t = time(NULL); tm = localtime(&t); + min = hour = mday = mon = wday = 0; fp = fopen(config, "r"); if (fp == NULL) { @@ -54,8 +55,6 @@ int main(int argc, char *argv[]) { continue; } - min = hour = mday = mon = wday = 0; - while (fgets(line, MAXLEN+1, fp) != NULL) { if (line[1] != '\0' && line[0] != '\043') { col = strtok(line,"\t"); @@ -108,11 +107,12 @@ int main(int argc, char *argv[]) { printf("dcron %.2d:%.2d %.2d.%.2d.%.4d\n", tm->tm_hour, tm->tm_min, tm->tm_mday, tm->tm_mon, tm->tm_year+1900); - printf("run: %s", cmd); syslog(LOG_NOTICE, "run: %s", cmd); - if (system(cmd)) + if (system(cmd)) { puts("ok"); + syslog(LOG_NOTICE, "ok"); + } } } } @@ -120,8 +120,9 @@ int main(int argc, char *argv[]) { } } } + fclose(fp); sleep(SLEEP); } - inthandler(); + inthandler(SIGINT); return 0; }