5 * Copyright 1994-1998 Matthew Dillon (dillon@backplane.com)
6 * Copyright 2009 James Pryor <profjim@jimpryor.net>
7 * May be distributed under the GNU General Public License
10 #include <sys/types.h>
12 #include <sys/ioctl.h>
14 #include <sys/resource.h>
33 #define Prototype extern
34 #define arysize(ary) (sizeof(ary)/sizeof((ary)[0]))
37 #define CRONTABS "/var/spool/cron/crontabs"
40 #define TIMESTAMPS "/var/spool/cron/timestamps"
43 #define TIMESTAMP_FMT "%Y-%m-%d %H:%M"
46 #define SCRONTABS "/etc/cron.d"
52 #define LOG_FILE "/var/log/crond.log"
55 #define LOG_IDENT "crond"
58 #define LOG_DATE_FMT "%b %e %H:%M:%S %%s " LOG_IDENT ": "
65 #define SENDMAIL "/usr/sbin/sendmail"
68 #define SENDMAIL_ARGS "-t", "-oem", "-i"
71 #define CRONUPDATE "cron.update"
74 #define MAXLINES 256 /* max lines in non-root crontabs */
77 #define PATH_VI "/usr/bin/vi" /* location of vi */
80 #define HOURLY_FREQ 60 * 60
81 #define DAILY_FREQ 24 * HOURLY_FREQ
82 #define WEEKLY_FREQ 7 * DAILY_FREQ
83 #define MONTHLY_FREQ 30 * DAILY_FREQ
84 #define YEARLY_FREQ 365 * DAILY_FREQ
87 #define WAIT_TAG "AFTER="
88 #define FREQ_TAG "FREQ="
90 #define VERSION "V4.0pre"
92 typedef struct CronFile
{
93 struct CronFile
*cf_Next
;
94 struct CronLine
*cf_LineBase
;
95 char *cf_DPath
; /* Directory path to cronfile */
96 char *cf_FileName
; /* Name of cronfile */
97 char *cf_UserName
; /* username to execute jobs as */
98 int cf_Ready
; /* bool: one or more jobs ready */
99 int cf_Running
; /* bool: one or more jobs running */
100 int cf_Deleted
; /* marked for deletion, ignore */
103 typedef struct CronLine
{
104 struct CronLine
*cl_Next
;
105 char *cl_Shell
; /* shell command */
106 char *cl_Description
; /* either "<cl_Shell>" or "job <cl_JobName>" */
107 char *cl_JobName
; /* job name, if any */
108 char *cl_Timestamp
; /* path to timestamp file, if cl_Freq defined */
109 struct CronWaiter
*cl_Waiters
;
110 struct CronNotifier
*cl_Notifs
;
111 int cl_Freq
; /* 0 (use arrays), minutes, -1 (noauto), -2 (startup) */
112 int cl_Delay
; /* defaults to cl_Freq or hourly */
115 int cl_Pid
; /* running pid, 0, or armed (-1), or waiting (-2) */
116 int cl_MailFlag
; /* running pid is for mail */
117 int cl_MailPos
; /* 'empty file' size */
118 char cl_Mins
[60]; /* 0-59 */
119 char cl_Hrs
[24]; /* 0-23 */
120 char cl_Days
[32]; /* 1-31 */
121 char cl_Mons
[12]; /* 0-11 */
122 char cl_Dow
[7]; /* 0-6, beginning sunday */
125 typedef struct CronWaiter
{
126 struct CronWaiter
*cw_Next
;
127 struct CronNotifier
*cw_Notifier
;
128 struct CronLine
*cw_NotifLine
;
133 typedef struct CronNotifier
{
134 struct CronNotifier
*cn_Next
;
135 struct CronWaiter
*cn_Waiter
;
138 // #define RUN_RANOUT 1
139 // #define RUN_RUNNING 2
140 // #define RUN_FAILED 3