Find the answer to your Linux question:
Results 1 to 2 of 2
I have written this script to delete files from a directory that are older then two days. find /Library/Webserver/Documents/caches/download/ -mtime +2 -exec rm {*.zip} \: -print. I would trigger this ...
  1. #1
    Just Joined!
    Join Date
    Jan 2008
    Posts
    1

    Script Testing

    I have written this script to delete files from a directory that are older then two days.

    find /Library/Webserver/Documents/caches/download/ -mtime +2 -exec rm {*.zip} \: -print.

    I would trigger this with Crontab.

    I would like to test this by producing a log file of what would have been deleted without actually deleting anything. Is this possible?

  2. #2
    Linux Guru
    Join Date
    Nov 2004
    Posts
    6,110
    The best thing to do with find is to change the exec command so that it will only echo or print the output. Also I would recommend using the iname switch rather than letting rm figure it out.
    Code:
    find /Library/Webserver/Documents/caches/download/ -iname *.zip -mtime +2 -exec echo {} > ~/find_test \;
    When you decide to add this to your crontab make sure you put in the full path to find and if outputting anything make sure you expand to full paths i.e. /home/jpawski rather than ~.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...