Linux cron 源码剖析

47次阅读

共计 843 个字符,预计需要花费 3 分钟才能阅读完成。

背景及 busybox 介绍
流程图

数据结构
typedef struct CronFile {
struct CronFile *cf_next;
struct CronLine *cf_lines;
char *cf_username;
smallint cf_wants_starting; /* bool: one or more jobs ready */
smallint cf_has_running; /* bool: one or more jobs running */
smallint cf_deleted; /* marked for deletion (but still has running jobs) */
} CronFile;

typedef struct CronLine {
struct CronLine *cl_next;
char *cl_cmd; /* shell command */
pid_t cl_pid; /* >0:running, <0:needs to be started in this minute, 0:dormant */
#define START_ME_REBOOT -2
#define START_ME_NORMAL -1
#if ENABLE_FEATURE_CROND_CALL_SENDMAIL
int cl_empty_mail_size; /* size of mail header only, 0 if no mailfile */
char *cl_mailto; /* whom to mail results, may be NULL */
#endif
char *cl_shell;
/* ordered by size, not in natural order. makes code smaller: */
char cl_Dow[7]; /* 0-6, beginning sunday */
char cl_Mons[12]; /* 0-11 */
char cl_Hrs[24]; /* 0-23 */
char cl_Days[32]; /* 1-31 */
char cl_Mins[60]; /* 0-59 */
} CronLine;

cron 使用方法
分析
代码

正文完
 0