Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2da5440

Browse files
committed
bug fix ssu_crond second, common write log
1 parent 27f8580 commit 2da5440

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

‎cron_support.c‎

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,28 +88,36 @@ extern char reservation_command[BUFFER_SIZE][MAX_BUFFER_SIZE];
8888
FILE *fp;
8989
time_t now_t;
9090
struct tm *now_tm;
91+
char temp[MAX_BUFFER_SIZE];
9192

92-
if ((fp = fopen(CRONTAB_LOG, "r+")) == NULL) {
93+
/*
94+
if ((fp = fopen(CRONTAB_LOG, "r+")) == NULL)
95+
{
9396
fprintf(stderr, "write_log: fopen error for %s\n", CRONTAB_LOG);
9497
return;
9598
}
9699
fseek(fp, 0, SEEK_END);
97-
100+
*/
98101
time(&now_t);
99102
now_tm = localtime(&now_t);
100103

101104
switch (command_type) {
102105
case ADD:
103-
fprintf(fp, "[%.24s] %s %s\n", asctime(now_tm), "add", command);
106+
sprintf(temp, "echo \"[%.24s] %s %s\" >> %s", asctime(now_tm), "add", command, CRONTAB_LOG);
107+
//fprintf(fp, "[%.24s] %s %s\n", asctime(now_tm), "add", command);
104108
break;
105109
case REMOVE:
106-
fprintf(fp, "[%.24s] %s %s\n", asctime(now_tm), "remove", command);
110+
sprintf(temp, "echo \"[%.24s] %s %s\" >> %s", asctime(now_tm), "remove", command, CRONTAB_LOG);
111+
//fprintf(fp, "[%.24s] %s %s\n", asctime(now_tm), "remove", command);
107112
break;
108113
case RUN:
109-
fprintf(fp, "[%.24s] %s %s\n", asctime(now_tm), "run", command);
114+
sprintf(temp, "echo \"[%.24s] %s %s\" >> %s", asctime(now_tm), "run", command, CRONTAB_LOG);
115+
//fprintf(fp, "[%.24s] %s %s\n", asctime(now_tm), "run", command);
110116
break;
111117
}
112-
fclose(fp);
118+
system(temp);
119+
//fflush(fp);
120+
//fclose(fp);
113121
}
114122

115123

‎ssu_crond.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ int main(int argc, char *argv[])
2121
struct stat statbuf;
2222
time_t now;
2323

24+
if (access(CRONTAB_LOG, F_OK) < 0)
25+
open(CRONTAB_LOG, O_CREAT);
26+
2427
// 마지막 수정 시간 획득
2528
fd = open(CRONTAB_FILE, O_RDONLY);
2629
fstat(fd, &statbuf);
@@ -103,12 +106,14 @@ void *reservation_execute(void *arg) // 예약 명령 실행 스레드
103106
// 현재 시간 추출
104107
now_t = time(NULL);
105108
now_tm = *localtime(&now_t);
109+
now_tm.tm_sec = 0;
106110

107111
while (true) {
108112

109113
now_tm.tm_min++;
110114
execute_t = mktime(&now_tm);
111115
now_tm = *localtime(&execute_t);
116+
now_tm.tm_sec = 0;
112117

113118
if (reservation_time_table[0][now_tm.tm_min] &&
114119
reservation_time_table[1][now_tm.tm_hour] &&

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /