- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: data archive
Operating System - HP-UX
1753481
Members
4483
Online
108794
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2008 05:41 AM
12-15-2008 05:41 AM
Re: data archive
Hi (again):
OK, so you want to examine the last modification timestamp of a directory and deduce the date 6-months ago, adjusted for year boundries. Use Perl:
# cat ./sixago
#!/usr/bin/perl
use strict;
use warnings;
use Time::Local;
my $dir = shift;
die "$0: directory expected\n" unless -d $dir;
my $moddate = ( stat($dir) )[9];
my ( $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst )
= localtime($moddate);
my $modtime = timelocal( 0, 0, 0, 15, $mon, $year ) - ( 180 * 86400 );
print join " ", ( split / /, localtime($modtime) )[ 1, 4 ], "\n";
1;
...run as:
# ./sixago /directory
For example:
# touch 02290800 /tmp/mydir
# ./sixago /tmp/mydir
Aug 2007
# touch /tmp/mydir
# ./sixago /tmp/mydir
Jun 2008
This works by fetching the last modification time (in seconds) for the directory. This is converted into a month-day-year-time format. The month and year are used and the day of the month set to 15. This modified date is then converted back to Epoch seconds and 180-days worth of seconds (one day = 86400 seconds) are subtracted. The new date in seconds is then converted to a month-day-year-time format and the local month name and year are extracted and returned.
Regards!
...JRF...
OK, so you want to examine the last modification timestamp of a directory and deduce the date 6-months ago, adjusted for year boundries. Use Perl:
# cat ./sixago
#!/usr/bin/perl
use strict;
use warnings;
use Time::Local;
my $dir = shift;
die "$0: directory expected\n" unless -d $dir;
my $moddate = ( stat($dir) )[9];
my ( $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst )
= localtime($moddate);
my $modtime = timelocal( 0, 0, 0, 15, $mon, $year ) - ( 180 * 86400 );
print join " ", ( split / /, localtime($modtime) )[ 1, 4 ], "\n";
1;
...run as:
# ./sixago /directory
For example:
# touch 02290800 /tmp/mydir
# ./sixago /tmp/mydir
Aug 2007
# touch /tmp/mydir
# ./sixago /tmp/mydir
Jun 2008
This works by fetching the last modification time (in seconds) for the directory. This is converted into a month-day-year-time format. The month and year are used and the day of the month set to 15. This modified date is then converted back to Epoch seconds and 180-days worth of seconds (one day = 86400 seconds) are subtracted. The new date in seconds is then converted to a month-day-year-time format and the local month name and year are extracted and returned.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2008 05:47 AM
12-15-2008 05:47 AM
Re: data archive
Hi (again):
...and to use the Perl script and return the date to your shell script, simply do:
...
./archive_tool $(./sixago /somedirectory)
or:
ARCHDATE=$(./sixago /somedirectory)
Regards!
...JRF...
...and to use the Perl script and return the date to your shell script, simply do:
...
./archive_tool $(./sixago /somedirectory)
or:
ARCHDATE=$(./sixago /somedirectory)
Regards!
...JRF...
- « Previous
-
- 1
- 2
- Next »
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP