@@ -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
0 commit comments