scron

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

commit 7b96c09e4c955ea1c488499ab5c2bf4a0953ad8f
parent 94582629a78e4b213882ab407dfd119a16342c09
Author: Ari Malinen <ari.malinen@gmail.com>
Date:   Mon, 30 Jun 2014 14:19:32 +0300

clearer README and crontab

Diffstat:
MREADME | 10+++++++---
Mcrond.c | 30+++++++++++++++---------------
Mcrontab | 2+-
3 files changed, 23 insertions(+), 19 deletions(-)

diff --git a/README b/README @@ -17,8 +17,12 @@ usage: crond [options] -d daemon -f <file> config file -example config --------------- -# tm_min, tm_hour, tm_mday, tm_mon, tm_wday, command +config +------ +value: * (wildcard), 30 (number) or 1-5 (range) +separator: \t (tab) + +example: +# tm_min tm_hour tm_mday tm_mon tm_wday command 0 6 * * * updatedb # 06:00 every day 30 5 * * 1-5 emerge --sync # 5:30 every weekday diff --git a/crond.c b/crond.c @@ -46,7 +46,7 @@ void arg(int argc, char *argv[]) { } int parsecolumn(char *col, int y, int x) { - int entry, entry2; + int value, value2; char *endptr, *endptr2; time_t t; struct tm *tm; @@ -57,11 +57,11 @@ int parsecolumn(char *col, int y, int x) { if (x >= 0 && x <= 4) { endptr = ""; endptr2 = ""; - entry = strtol(col, &endptr, 0); - entry2 = -1; + value = strtol(col, &endptr, 0); + value2 = -1; if (*endptr == '-') { endptr++; - entry2 = strtol(endptr, &endptr2, 0); + value2 = strtol(endptr, &endptr2, 0); endptr = ""; } @@ -70,19 +70,19 @@ int parsecolumn(char *col, int y, int x) { } else if (*endptr != '\0' || *endptr2 != '\0') { fprintf(stderr, "error: %s line %d column %d\n", config, y+1, x+1); syslog(LOG_WARNING, "error: %s line %d column %d", config, y+1, x+1); - } else if (entry2 == -1) { - if ((x == 0 && entry == tm->tm_min) || - (x == 1 && entry == tm->tm_hour) || - (x == 2 && entry == tm->tm_mday) || - (x == 3 && entry == tm->tm_mon) || - (x == 4 && entry == tm->tm_wday)) + } else if (value2 == -1) { + if ((x == 0 && value == tm->tm_min) || + (x == 1 && value == tm->tm_hour) || + (x == 2 && value == tm->tm_mday) || + (x == 3 && value == tm->tm_mon) || + (x == 4 && value == tm->tm_wday)) return 0; } else { - if ((x == 0 && entry <= tm->tm_min && entry2 >= tm->tm_min) || - (x == 1 && entry <= tm->tm_hour && entry2 >= tm->tm_hour) || - (x == 2 && entry <= tm->tm_mday && entry2 >= tm->tm_mday) || - (x == 3 && entry <= tm->tm_mon && entry2 >= tm->tm_mon) || - (x == 4 && entry <= tm->tm_wday && entry2 >= tm->tm_wday)) + if ((x == 0 && value <= tm->tm_min && value2 >= tm->tm_min) || + (x == 1 && value <= tm->tm_hour && value2 >= tm->tm_hour) || + (x == 2 && value <= tm->tm_mday && value2 >= tm->tm_mday) || + (x == 3 && value <= tm->tm_mon && value2 >= tm->tm_mon) || + (x == 4 && value <= tm->tm_wday && value2 >= tm->tm_wday)) return 0; } } diff --git a/crontab b/crontab @@ -1 +1 @@ -# tm_min, tm_hour, tm_mday, tm_mon, tm_wday, command +# tm_min tm_hour tm_mday tm_mon tm_wday command