root/docs/usc/nemo/usr2/home/jcothran/cc/copy_steps.pl
| Revision 108 (checked in by jcothran, 2 years ago) |
|---|
| Line | |
|---|---|
| 1 | #!/usr/bin/perl |
| 2 | |
| 3 | use strict; |
| 4 | |
| 5 | # $time_offset = number of hours older than current time to assign time_start ; this is working on the idea that new data is arriving into the database all the time, but after a certain number of hours we can assume that we have collected all the data we are going to collect |
| 6 | my $time_offset = 336; #336 = 2 weeks |
| 7 | |
| 8 | # $time_interval = number of hours between time_start and time_stop ; should be equal to the time interval between when the cron job which calls this process is run, so if 168 = 1 week, then the cron should also be run once a week |
| 9 | my $time_interval = 168; #168 = 1 week |
| 10 | |
| 11 | ################################################# |
| 12 | |
| 13 | my $time_zone_offset = `date '+%z'`; |
| 14 | chomp($time_zone_offset); |
| 15 | $time_zone_offset = substr($time_zone_offset,0,-2); |
| 16 | |
| 17 | #3600 sec/hour |
| 18 | |
| 19 | my $sec_now = `date '+%s'`; |
| 20 | chomp($sec_now); |
| 21 | $sec_now = $sec_now + $time_zone_offset*3600; |
| 22 | |
| 23 | my $sec_time_start = $sec_now - $time_offset*3600; |
| 24 | my $sec_time_stop = $sec_now - $time_offset*3600 - $time_interval*3600; |
| 25 | |
| 26 | my $time_start = `date -d '1970-01-01 $sec_time_start seconds' +"%Y_%m_%d_%H%z"`; |
| 27 | chomp($time_start); |
| 28 | $time_start = substr($time_start,0,-2); |
| 29 | |
| 30 | my $time_stop = `date -d '1970-01-01 $sec_time_stop seconds' +"%Y_%m_%d_%H%z"`; |
| 31 | chomp($time_stop); |
| 32 | $time_stop = substr($time_stop,0,-2); |
| 33 | |
| 34 | #uncomment for manual testing purposes |
| 35 | #my $time_start = '2007_01_01_00-05'; |
| 36 | #my $time_stop = '2007_02_01_00-05'; |
| 37 | |
| 38 | #print $time_start."\n"; |
| 39 | #print $time_stop."\n"; |
| 40 | |
| 41 | `perl process_copy.pl environment_copy.xml create $time_start $time_stop`; |
| 42 | `perl process_copy.pl environment_copy.xml copy $time_start $time_stop`; |
| 43 | |
| 44 | #the below delete step is commented out initially, uncomment when confident that the earlier steps and copy file creation is working |
| 45 | #`perl process_copy.pl environment_copy.xml delete $time_start $time_stop`; |
| 46 | |
| 47 | #may want to include database commands for 'vacuum analyze' or 'reindex' here as needed |
| 48 | |
| 49 | exit 0; |
| 50 |
Note: See TracBrowser for help on using the browser.
