> Why do you convert the mtime (a Time object) to an integer? Time
> objects are comparable. Try to omit the ".to_i" and compare the
> Time objects that represent the mtimes.
> 
> Regards,
> Daniel

HI!

I feel like Im smoking crack and getting pissed off at the same time! No 
offence intended!
This is still not working as I should be seeing
/backups/prod_db_bkup_Thr2009-10-291052.gz
as the oldest file.


 require 'time'
    stats = Hash.new
    DB_BKUP1.each do |dbfile|
        stats[dbfile] = [File.stat(dbfile).mtime]
    end

    stats_sorted = Hash.new
    stats_sorted = stats.sort { |x,y| x[1]<=>y[1] }

    oldest = stats_sorted[0][1].first
    p oldest
    oldestfile = ''
    stats.each_value do |v|
        if  #{v} < #{oldest}
            oldest = v
            oldestfile = stats.index(oldest)
        end
    end
    puts oldestfile
    puts "exit"
    exit
end

prod_DB_OS_bkup.rb: 108 lines, 2997 characters.
[root / .../usr/local/vrep/OS_scripts]# ruby prod_DB_OS_bkup.rb
Thu Oct 29 10:52:41 -0400 2009
/backups/prod_db_bkup_Thr2009-10-291054.gz
exit

[root / .../usr/local/vrep/OS_scripts]# ls -alrt /backups/prod*.gz
-rw-r--r--  1 root  wheel  38608780 Oct 29 10:52 
/backups/prod_db_bkup_Thr2009-10-291052.gz
-rw-r--r--  1 root  wheel  38608793 Oct 29 10:54 
/backups/prod_db_bkup_Thr2009-10-291054.gz
-rw-r--r--  1 root  wheel  38608802 Oct 29 11:00 
/backups/prod_db_bkup_Thr2009-10-29110.gz
-rw-r--r--  1 root  wheel  38609193 Oct 30 10:42 
/backups/prod_db_bkup_Fri2009-10-301042.gz
-rw-r--r--  1 root  wheel  38770872 Nov  1 16:29 
/backups/prod_db_bkup_Sun2009-11-011629.gz

-- 
Posted via http://www.ruby-forum.com/.