61 lines
1.3 KiB
C
61 lines
1.3 KiB
C
#include "monitsys.h"
|
|
|
|
void main(void)
|
|
{
|
|
FILE *fd = NULL,*fp = NULL;
|
|
unsigned int cronum = 0;
|
|
char buff[128]="\0";
|
|
char buff1[]="no";
|
|
|
|
system("crontab -l > /root/cheng/cron.txt 2>&1");
|
|
system("chmod 777 /root/cheng/cron.txt");
|
|
fd = fopen("/root/cheng/cron.txt","r");
|
|
|
|
|
|
while(NULL != fgets(buff,sizeof(buff),fd))
|
|
{
|
|
cronum++;
|
|
continue;
|
|
}
|
|
if(cronum == 1)
|
|
{
|
|
|
|
// if(NULL==(fp = popen("crontab -l","r")))
|
|
|
|
// {
|
|
// fprintf(stdout,"execute crontab failed: ");
|
|
// return 0;
|
|
//}
|
|
fscanf(fd, "%s",buff);
|
|
buff[2]='\0';
|
|
if(strcmp(buff,buff1)==0)
|
|
printf("there is no date");
|
|
else
|
|
|
|
printf("there is date");
|
|
|
|
printf("data in buff is %s\n",buff);
|
|
}
|
|
// cronum = 0;
|
|
// printf("There is no date");
|
|
|
|
// if(NULL==(fd = popen("crontab -l","r")))
|
|
|
|
//{
|
|
// fprintf(stdout,"execute crontab failed: ");
|
|
//return 0;
|
|
//}
|
|
|
|
|
|
//fgets(buff,sizeof(buff),fd);
|
|
// fscanf(fd, "%s",buff);
|
|
// pronum = atoi(buff);
|
|
// if(buff[0] != 'n')
|
|
|
|
//printf("buff is %s \n ",buff);
|
|
|
|
fclose(fd);
|
|
return 0;
|
|
}
|
|
|