Find the answer to your Linux question:
Results 1 to 5 of 5
Hello I am trying to write an app in which after a file is created, it must be moved out in 10 mins. ie if after 10 mins I find ...
  1. #1
    Just Joined!
    Join Date
    Jan 2008
    Posts
    22

    Timers in C

    Hello
    I am trying to write an app in which after a file is created, it must be moved out in 10 mins. ie if after 10 mins I find the file still open and present then I do something.
    My problem is in being able to measure these 10 mins . Is there any sort of a timer in C, such that I can start it when I create the file and stop/reset it when I move it. If it reaches 10 mins then I go to the handler and write some code to handle it.

    Ie i need some timer event in C.

    thanks

  2. #2
    Linux Enthusiast gerard4143's Avatar
    Join Date
    Dec 2007
    Location
    Canada, Prince Edward Island
    Posts
    714
    Not really sure what you want to do but you could try alarm();

  3. #3
    Just Joined!
    Join Date
    Jan 2008
    Posts
    22
    alarm only works on single threads.

    I have a single threaded app and I have multiple files that I open at different times, every 5 mins I move the files to another directory and create another new one in its place.
    So If I see that a file has been here for more than 10 mins I want to handle it differently.

  4. #4
    Linux Enthusiast gerard4143's Avatar
    Join Date
    Dec 2007
    Location
    Canada, Prince Edward Island
    Posts
    714
    Try the stat() function it will give you all kinds of file info like creation time

  5. #5
    Just Joined!
    Join Date
    Jan 2008
    Posts
    22
    I know, but how do I do this every 10 mins ?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...