|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
hi @ all!
here's the problem: our mailserver needs cleanup, he uses qmail and virtual hosts. the mails are stored in folder tree like that: /home/virthosts/foo_host/foo_user@foo_host/cur/foo_mail now every mail is stored on the server and the folders get stuffed with rubbish nobody needs any more. so i got the job to write a bash script to delete mails, that are older than 30 days to include into the cron-job. this scipt is working well, it enters the directories right and deletes the files, but: i wasn't able to find out how to determine the age of a file so the script deletes only the right files! anybody any idea? regards, thedarkzone |
|
#2
|
|||
|
|||
|
Have a look at the "find" command. ("man find")
It can find files that are older than a given date. One comment: Donīt pass itīs output to "xargs" because on some systems it does not escape spaces in filenames. use the "-exec" switch or directly "-delete" instead.
__________________
-- Manuel Hirsch - Linux, FreeBSD, programming, administration articles, tutorials and more. |
![]() |
| Viewing: Dev Shed Forums > Other > Beginner Programming > bash script to determine the age of a file |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|