On 03/15/04 14:24, Norman Zhang wrote:
I've /share_folder with many user folders.

e.g.,

/share_folder/user_a
/share_folder/user_b
...

I would like to scan all user folders for files that are older than 30 days and delete them. Is this doable with Perl?


What do you mean by "older than 30 days"?


I mean files that were created 30 days ago. I disabled atime on my share_folder/ partition for faster access.

/dev/scsi/host0/bus1/target2/lun0/part1 /usrswap xfs rw,noatime,usrquota,grpquota 0 0

Thus, is it safe to assume the following script won't work?

You can only base it on properties stored by the filesystem. Maybe -mtime (last modified time) is close enough?


Is there a specific reason you're using perl for this task? You can accomplish the same with:

find /share_folder -mtime +30 | xargs rm

but you should probably verify the correctness of the command first with

find /share_folder -mtime +30 | xargs ls


You can use the perl utility 'find2perl' to generate the code for you:

find2perl /share_folder -atime +30 > rmoldshares.pl

produces a file 'rmoldshares.pl' that contains perl code to find all files in '/share_folder' that have an access time of 30 days or more. You can then modify it to call 'unlink' on the found files.


Regards,
Norman



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to