Pol Hallen:
> 
> I try to redirect output of this script to file (using tee) and also send
> it to mail
> 
> the script deletes files older than 150days:
> 
> find /share/.trash/ -type f -atime +150 -exec rm -fr {}  \;

- atime finds files *last accessed* 150 days ago. You probably need
  mtime instead. I am not even sure whether running the script will
  change the atime of all files in the directory and thus prevent
  anything in it to be deleted. You should make sure that the filesystem
  is not mounted with "relatime" or "noatime" as well when using atime.

- You are starting an rm process for every file to delete. You can end
  the command with "+" instead of "\;" to make find pass as many files
  to rm as possible. If you delete many files that way, that may make a
  big difference spped-wise.

- Do you want to have the list mailed as an attachment? -Then I would
  just redirect the output to a file and use mutt's batch mode to send
  the file (mutt -x -a $file).

- Otherwise, I would still redirect first and then send the mail as an
  additional step:

  find … > file
  mail -s "$subject" $recipient < file

- If you insist:

  find … | tee [-a] file | mail -s "$subject" $recipient

  "tee -a" appends to "file", leaving out "-a" will overwrite "file".

J.
-- 
I wish I had been aware enough to enjoy my time as a toddler.
[Agree]   [Disagree]
                 <http://www.slowlydownward.com/NODATA/data_enter2.html>

Attachment: signature.asc
Description: Digital signature

Reply via email to