Archiving files in "date folders" based on date and time file generated

Archiving files in "date folders" based on date and time file generated

Post by Jeff Canni » Wed, 18 Jul 2001 18:32:29



Hi,

Please consider the following: Normally files that are generated as
"results" files from service fulfillment events are stored in a
standard archive directory
called say "~/services_results/DD-MM-YYYY/Name_of_Results_File. This
essentially
means all files generated on July,16,2001 between 0:00:01 and 23:59:60
are
archived in the "~/services_results/16-07-2001" directory. The same
holds for each respective day and is very straight-forward.

However, due to operational issues there is now a need to do a split
whereby the service results files are stored in particular "date
folders" based on time of day generated as well. For example:

* If the service fulfillment events occur between "6AM.July.16.2001",
  and "6AM.July.17.2001", then the results files are to be stored in
the folder
  "~/services_results/16-07-2001.
* If the service fulfillment events occur between "6AM.July.17.2001"
and     "6AM.July.18.2001", then the results files are to be stored in
the folder       "~/services_results/17-07-2001".

This new methodology is to be employed indefinitely until operational
methods change at some unforeseen time in the future.

If someone has a rather quick "fix" for this scenario, it would be
greatly appreciated. The operating environment is Solaris.

Regards,
Jeff
_______

 
 
 

Archiving files in "date folders" based on date and time file generated

Post by steve ove » Wed, 18 Jul 2001 22:41:34



> Hi,

> Please consider the following: Normally files that are generated as
> "results" files from service fulfillment events are stored in a
> standard archive directory
> called say "~/services_results/DD-MM-YYYY/Name_of_Results_File. This
> essentially
> means all files generated on July,16,2001 between 0:00:01 and 23:59:60
> are
> archived in the "~/services_results/16-07-2001" directory. The same
> holds for each respective day and is very straight-forward.

> However, due to operational issues there is now a need to do a split
> whereby the service results files are stored in particular "date
> folders" based on time of day generated as well. For example:

> * If the service fulfillment events occur between "6AM.July.16.2001",
>   and "6AM.July.17.2001", then the results files are to be stored in
> the folder
>   "~/services_results/16-07-2001.
> * If the service fulfillment events occur between "6AM.July.17.2001"
> and     "6AM.July.18.2001", then the results files are to be stored in
> the folder       "~/services_results/17-07-2001".

> This new methodology is to be employed indefinitely until operational
> methods change at some unforeseen time in the future.

> If someone has a rather quick "fix" for this scenario, it would be
> greatly appreciated. The operating environment is Solaris.

> Regards,
> Jeff
> _______

well maybe someone has code for this but with all the checking for
leap years n all I suppose i'd rather let the "C" libraries do the
checking for me

steve

 
 
 

Archiving files in "date folders" based on date and time file generated

Post by Matt » Thu, 19 Jul 2001 04:49:17


I have done something similar recently.

Are you modifying a script or piece of C?

If its a script and there is a line that looks something like....
LOGFILE="~/services_results/`date +%d%m%Y`/Name_of_Results_File"

Then a quick fix is to do the following....
TZ=BST+6;export TZ
LOGFILE="~/services_results/`date +%d%m%Y`/Name_of_Results_File"
unset TZ

If you are in the UK, you would need to expand this to check what the
current timezone is and use GMT when we enter GMT.

Something like....
THISTZ=`date | sed 's/.*\(BST\).*$/\1/'|sed 's/.*\(GMT\).*$/\1/'`
TZ=$THISTZ+6;export TZ
LOGFILE="~/services_results/`date +%d%m%Y`/Name_of_Results_File"
unset TZ

Not sure how to do the BST/GMT swap in one sed command (if anyone out there
wants to help me out there!)

Hope this helps!

Matt


Quote:> Hi,

> Please consider the following: Normally files that are generated as
> "results" files from service fulfillment events are stored in a
> standard archive directory
> called say "~/services_results/DD-MM-YYYY/Name_of_Results_File. This
> essentially
> means all files generated on July,16,2001 between 0:00:01 and 23:59:60
> are
> archived in the "~/services_results/16-07-2001" directory. The same
> holds for each respective day and is very straight-forward.

> However, due to operational issues there is now a need to do a split
> whereby the service results files are stored in particular "date
> folders" based on time of day generated as well. For example:

> * If the service fulfillment events occur between "6AM.July.16.2001",
>   and "6AM.July.17.2001", then the results files are to be stored in
> the folder
>   "~/services_results/16-07-2001.
> * If the service fulfillment events occur between "6AM.July.17.2001"
> and     "6AM.July.18.2001", then the results files are to be stored in
> the folder       "~/services_results/17-07-2001".

> This new methodology is to be employed indefinitely until operational
> methods change at some unforeseen time in the future.

> If someone has a rather quick "fix" for this scenario, it would be
> greatly appreciated. The operating environment is Solaris.

> Regards,
> Jeff
> _______

 
 
 

Archiving files in "date folders" based on date and time file generated

Post by steve ove » Thu, 19 Jul 2001 19:27:35



> I have done something similar recently.

> Are you modifying a script or piece of C?

> If its a script and there is a line that looks something like....
> LOGFILE="~/services_results/`date +%d%m%Y`/Name_of_Results_File"

> Then a quick fix is to do the following....
> TZ=BST+6;export TZ
> LOGFILE="~/services_results/`date +%d%m%Y`/Name_of_Results_File"
> unset TZ

> If you are in the UK, you would need to expand this to check what the
> current timezone is and use GMT when we enter GMT.

> Something like....
> THISTZ=`date | sed 's/.*\(BST\).*$/\1/'|sed 's/.*\(GMT\).*$/\1/'`
> TZ=$THISTZ+6;export TZ
> LOGFILE="~/services_results/`date +%d%m%Y`/Name_of_Results_File"
> unset TZ

> Not sure how to do the BST/GMT swap in one sed command (if anyone out there
> wants to help me out there!)

> Hope this helps!

> Matt

sorry to be pick-y Matt but I suspect that should be
TZ=${my_time_zone}-6
so that 0559 17/7/01 goes into 16/7/01 (UK day/month order) - but at
least you avoid serious programming (by using seriuous deviousness).
Depending on shell in use may need TZ=`expr ${my_time_zone} - 6` or
similar.The timezone to use could be interesting - system wide or
personnal?

steve

 
 
 

Archiving files in "date folders" based on date and time file generated

Post by Matt » Sat, 21 Jul 2001 02:53:39


Not exactly sure if it is + or - now.  I think I am right with the + as it
works the opposite way that you would think!
+6 onto 19:00 would give 13:00 thus the rollover date would be 6 hours after
midnight which would be correct as to the spec.

It is not an arithmetic function as such, so you wouldn't use expr.
You might well need ${THISTZ}+6

If he's using csh he should use

setenv  TZ  $THISTZ+6
blah
unsetenv TZ

The timezone modification only effects the current shell



Quote:> > I have done something similar recently.

> > Are you modifying a script or piece of C?

> > If its a script and there is a line that looks something like....
> > LOGFILE="~/services_results/`date +%d%m%Y`/Name_of_Results_File"

> > Then a quick fix is to do the following....
> > TZ=BST+6;export TZ
> > LOGFILE="~/services_results/`date +%d%m%Y`/Name_of_Results_File"
> > unset TZ

> > If you are in the UK, you would need to expand this to check what the
> > current timezone is and use GMT when we enter GMT.

> > Something like....
> > THISTZ=`date | sed 's/.*\(BST\).*$/\1/'|sed 's/.*\(GMT\).*$/\1/'`
> > TZ=$THISTZ+6;export TZ
> > LOGFILE="~/services_results/`date +%d%m%Y`/Name_of_Results_File"
> > unset TZ

> > Not sure how to do the BST/GMT swap in one sed command (if anyone out
there
> > wants to help me out there!)

> > Hope this helps!

> > Matt

> sorry to be pick-y Matt but I suspect that should be
> TZ=${my_time_zone}-6
> so that 0559 17/7/01 goes into 16/7/01 (UK day/month order) - but at
> least you avoid serious programming (by using seriuous deviousness).
> Depending on shell in use may need TZ=`expr ${my_time_zone} - 6` or
> similar.The timezone to use could be interesting - system wide or
> personnal?

> steve

 
 
 

Archiving files in "date folders" based on date and time file generated

Post by steve ove » Sun, 22 Jul 2001 00:34:08



> Not exactly sure if it is + or - now.  I think I am right with the + as it
> works the opposite way that you would think!
> +6 onto 19:00 would give 13:00 thus the rollover date would be 6 hours after
> midnight which would be correct as to the spec.

> It is not an arithmetic function as such, so you wouldn't use expr.
> You might well need ${THISTZ}+6

> If he's using csh he should use

> setenv  TZ  $THISTZ+6
> blah
> unsetenv TZ

> The timezone modification only effects the current shell

my appologies, I hadn't tried it - have now, it appears to work with
reverse logic... also from my results :

# date
Fri Jul 20 16:24:31 2001
# TZ=BST-6
# export TZ
# date
Fri Jul 20 21:24:53 2001   # ie BST-6 advanced clock 5 hours
# TZ=BST+6
# export TZ
# date
Fri Jul 20 09:25:32 2001   # ie BST+6 decremented clock 7 hours
#

it looks like you might need BST+5 ! (of course it could be my
implementation)

steve