using strncmp with current time

Hi

I was writing a program to run the code at every noon

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
   time_t rawtime;
   time (&rawtime);
   while(1)
   {
      if(strncmp(ctime(&rawtime),"12:00:00",8) == 0)
      {
         printf("check");
         some code
      }
   }
   return 0;
}


but that if-statment doesn't seem to run at noon

can anyone help me with this?

thanks in advance
You are doing an infinite while loop and hope that you are able to capture at EXACTLY 12:00:00 ? Hmmm..... usually for such task, we use the crontab to configure and it seems quite pretty accurate. How cron daemon is implemented to be so accurate is beyond me but as long as it provide me the feature to do what I want, I am happy. You may want to check out crontab ? :P
Topic archived. No new replies allowed.