Mtime or the equivalent for HP-UX


Login or Register to Reply

 
Thread Tools Search this Thread
# 8  
Old 3 Weeks Ago
You could use perl to test if file is older that 3 days like this:

Code:
$ FILE=.profile
$  perl -e 'use File::stat;  my $INODE=stat("'$FILE'"); exit((time() - $INODE->mtime) < 3600*24*3);' && echo "File $FILE is old"
File .profile is old

Or (not a big perl coder so this could probably be simplified). Print filenames on stdin, older than 3 days:

Code:
$ ls | perl -e '
  use File::stat;
  while (my $fl = <STDIN>) { 
    chomp $fl ;
    my $INODE=stat($fl); 
    if(time() - $INODE->mtime > 3600*24*3) { 
       print $fl . "\n";
    } 
  }'


Last edited by Chubler_XL; 3 Weeks Ago at 06:07 PM.. Reason: Clean up formatting
# 9  
Old 3 Weeks Ago
Chubler_XL - yes and no.

One problem - lpstat -o reports data from the print queue acceptance time, not the mtime of a file. In other words, you could send a 10 year old file to a print queue and acceptance time would be in the last few seconds. Try it if you have an HP-UX box handy.

Perl definitely is an option, but IIRC timelocal (and some other) and other date time .pm files were not on the last HP-UX boxes I worked on ( 11i v3 (B.11.31), 2007-02-01 ) as default installed items in perl.

Adding new perl modules requires going to cpan and downloading, then creating library directories and environment variables. And then coding. No biggie. But it is a system change.

My effort was simply in C because this was just a quick effort for me. And hoping it was useful. The missing year number part was what got me interested.
These 2 Users Gave Thanks to jim mcnamara For This Post:
Chubler_XL (3 Weeks Ago) Neo (3 Weeks Ago)
Login or Register to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Mtime issue arrals_vl Shell Programming and Scripting 4 10-27-2014 05:30 AM
Find by name and mtime Jazmania Shell Programming and Scripting 2 01-11-2012 04:49 AM
rsync and mtime dlam UNIX for Dummies Questions & Answers 2 12-05-2011 03:46 AM
Find using mtime vsekvsek UNIX for Dummies Questions & Answers 2 08-17-2011 03:31 PM
-mtime command umair Red Hat 1 03-19-2011 10:19 AM
find -mtime +7 prakashoracledb Shell Programming and Scripting 10 12-09-2010 06:06 PM
(find) mtime vs. (unix) mtime hiddenshadow UNIX for Dummies Questions & Answers 2 12-15-2009 08:25 AM
-mtime Problem Gbyte AIX 1 07-30-2009 11:59 PM
mtime ss_ss Shell Programming and Scripting 4 02-25-2009 12:16 AM
-mtime +30 Blue68 UNIX for Dummies Questions & Answers 1 01-05-2009 01:48 AM
problem in mtime manas_ranjan Shell Programming and Scripting 2 12-24-2007 03:45 AM
mtime ravi raj kumar Shell Programming and Scripting 7 03-01-2007 07:54 PM
mtime help!!!!! scooter17 UNIX for Dummies Questions & Answers 2 09-12-2006 02:24 PM
find . -mtime topcat8 UNIX for Dummies Questions & Answers 1 04-26-2006 10:55 AM
mtime vs ctime moxxx68 UNIX for Dummies Questions & Answers 3 11-06-2004 09:57 PM