how to copy a file each 6 minutes

Hi everyone,
Right now I'm working with streams, I have to sense something and save the result 'continuously', the trick is that every six minutes I have to stop, make a copy from the original file, re create the original file, and start again (is a block in gnuradio -just giving more info -).
I don't know how to track the 6 minutes period, any suggestion?

thanks in advance

I wrote this a while ago
I wrote this for someone else and figured they would want to know that it was still working.

If you never want to see any msgs, take out everything but the sleep function and loop it.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Delay for x mins
// Change runtime # to increase or decrease time.
#include <iostream>
#include <windows.h>

using namespace std;

     int m(0);
     int g(0);
     int runtime (6); // How many times you want the program to loop.

void countdownminutes()
{
     cout << "Counting down from " << runtime << " minutes\n";
     cout << " Press CTRL-C to exit\n";
     while (m != runtime)
     {
// This will cause a 1 min delay, spit out a msg and sleep again
     Sleep (60000); // 1000ms = 1 sec  60000 = 1 min  600000 = 10 min
     m = (m+1);
     g = (runtime - m);
     cout << g << " mins to go..." << endl;
     }
     cout << runtime << " min delay reached\n";
}

int main ()
{
countdownminutes();
return 0;
}
Last edited on
I have same Question...
infinite loop
{
sleep(6minutes); // in milliseconds
copy files;
}


or

clock_t begin = clock();
clock_t end = clock();
double passed_time = double(end - begin) / CLOCKS_PER_SEC; //in seconds
To do something every 6 minutes, I suggest boost.asio's async timer facility:

http://www.boost.org/doc/libs/release/doc/html/boost_asio/tutorial/tuttimer3.html

or your own thread that calls std::this_thread::sleep_for(std::chrono::minutes(6) in a loop

but there's this "I have to stop" that makes me wonder: what exactly has to be stopped?
Topic archived. No new replies allowed.