
29 Jan
2007
29 Jan
'07
6:26 p.m.
-- Here's my contribution to the "Haskell" way to do it import Directory (renameFile) import System.FilePath import System.Path.Glob (glob) import System.Time basenames = [ "mail.log", "thttpd.log" ] logdir = "/var/log" archivedir = "/var/log/archive" main = forM_ bases $ \base -> do olds <- glob $ logdir > base <.> "*.gz" forM_ olds $ \old -> do now <- timestamp old let new = archivedir > basename <.> now <.> "gz" printf "mv %s %s" old new renameFile old new timestamp f = do t <- getModificationTime return $ formatCalendarTime defaultTimeLocale "%Y%m%d" (toUTCTime t)