Hi All,

I have been given a task of checking the size of file in Linux machine using C Program.

Below is what I came up with

Code:
#include <stdio.h>
void main(int argc, char **argv)
{
 FILE *fp;
   char ch;
 int size = 0;
 fp = fopen(argv[1], "r");
 if (fp == NULL)
    printf("\n Failure ");
    else 
       printf("\success ");
    fseek(fp, 0, 2);    
    size = ftell(fp);   
    printf("The size of given file is : %d\n", size);    
    fclose(fp);
}

But Now I have been asked to modify this code in a way that instead of passing the file name as parameter, I have to make a database connection and fetch the value of the filename and location from the database table and check the size . My program has to repeat this process every ten minutes, which means every ten minutes my program has to hit the database, fetch the value and check the size in the file system.



I heard like I Have to create a Fork Call, and have the child instance run every ten minutes.

I am new to C Programming, I could only come up with above code.
Please give an example of how to achieve my requirement.