@@ -58,7 +58,7 @@ void free_command_token(CommandToken *command) // 명령행 구조체 초기화
58
58
/**
59
59
* @brief 예약 명령 목록 가져오기
60
60
*/
61
- int get_reservation_command (void ) // 예약 명령 목록 가져오
61
+ int get_reservation_command (void ) // 예약 명령 목록 가져오기
62
62
{
63
63
FILE * fp ;
64
64
@@ -89,10 +89,10 @@ void write_log(int command_type, char *command) // 로그 파일에 이력 기
89
89
time_t now_t ;
90
90
struct tm * now_tm ;
91
91
92
- pthread_mutex_lock (& mutex );
92
+ pthread_mutex_lock (& mutex );// Mutex lock을 통해 Thread-safe 하게 로그 저장
93
93
94
- if ((fp = fopen (CRONTAB_LOG , "r+" )) == NULL )
95
- fp = fopen (CRONTAB_LOG , "w" );
94
+ if ((fp = fopen (CRONTAB_LOG , "r+" )) == NULL )// 로그 파일이 존재하지 않을 경우
95
+ fp = fopen (CRONTAB_LOG , "w" );// 로그 파일 생성
96
96
97
97
fseek (fp , 0 , SEEK_END );
98
98
@@ -101,15 +101,12 @@ void write_log(int command_type, char *command) // 로그 파일에 이력 기
101
101
102
102
switch (command_type ) {
103
103
case ADD :
104
- //sprintf(temp, "echo \"[%.24s] %s %s\" >> %s", asctime(now_tm), "add", command, CRONTAB_LOG);
105
104
fprintf (fp , "[%.24s] %s %s\n" , asctime (now_tm ), "add" , command );
106
105
break ;
107
106
case REMOVE :
108
- //sprintf(temp, "echo \"[%.24s] %s %s\" >> %s", asctime(now_tm), "remove", command, CRONTAB_LOG);
109
107
fprintf (fp , "[%.24s] %s %s\n" , asctime (now_tm ), "remove" , command );
110
108
break ;
111
109
case RUN :
112
- //sprintf(temp, "echo \"[%.24s] %s %s\" >> %s", asctime(now_tm), "run", command, CRONTAB_LOG);
113
110
fprintf (fp , "[%.24s] %s %s\n" , asctime (now_tm ), "run" , command );
114
111
break ;
115
112
}
0 commit comments