[Dovecot] OT: Cron Output When Deleting Files
I have a Dovecot setup for a personal e-mail server. I have a cron job setup each evening which runs the following command to delete old messages from my Deleted Items folder.
find ./ -type f -ctime +14 | xargs rm
I don't know that much about bash scripting. I would like the output to tell me how many files were deleted. Can anybody share with me how can I get that done, or point in the correct direction?
Thanks, Jeff
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On Tue, 16 Oct 2007, Jeff Grossman wrote:
find ./ -type f -ctime +14 | xargs rm
I don't know that much about bash scripting. I would like the output to tell me how many files were deleted. Can anybody share with me how can I get that done, or point in the correct direction?
find ./ -type f -ctime +14 |tee /tmp/find-rm | xargs rm wc -l /tmp/find-rm rm /tmp/find-rm
Bye,
Steffen Kaiser -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux)
iQEVAwUBRxS51C9SORjhbDpvAQJp+Qf+I3Twhiy+Dm/eCONt5e4AtaSkL4JS6HJV 0Wj9YYLVBDS0sTxgqzg4n2M+Zmk8YN6Q/k/3SRByWLR6f5xs7IoIMaRefLhaGF4B 22MGDhE4XRefI+bGwUtELGzeg69qcJ8/dZHuqfXlTNzErO5bgeyE8bX8GHaLxThY KBevhv2z+DOWX7pr2TyPQ/nwbWge2L3f2pFdAXDdgqj848KLuxsqwDlB+Ohz/WHA yO3XxW5wFCzE3DmNDCPFMfjF1ZIhqHkkWWjej8ig1WDbcwnBI3Tbtx52FRXNQpXn NRNFXaITbfRxL7ZIsD42WhafiXqyPZ7eO62xbZ4B6463F3oT4UfdFA== =IOij -----END PGP SIGNATURE-----
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On Tue, Oct 16, 2007 at 03:17:06PM +0200, Steffen Kaiser wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On Tue, 16 Oct 2007, Jeff Grossman wrote:
find ./ -type f -ctime +14 | xargs rm
I don't know that much about bash scripting. I would like the output to tell me how many files were deleted. Can anybody share with me how can I get that done, or point in the correct direction?
find ./ -type f -ctime +14 |tee /tmp/find-rm | xargs rm wc -l /tmp/find-rm rm /tmp/find-rm
Or, having the right version of rm:
find ./ -type f -ctime +14 | xargs rm -v | wc -l
regards
- -- tomas -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux)
iD8DBQFHFMhnBcgs9XrR2kYRAlY5AJsHaVgFfM/3fZHX8afVSqZjD9GBMACeKD0a Zm2ZzYfl4S6olYb2a7oz49g= =9uRg -----END PGP SIGNATURE-----
tomas@tuxteam.de wrote:
On Tue, 16 Oct 2007, Jeff Grossman wrote:
find ./ -type f -ctime +14 | xargs rm
I don't know that much about bash scripting. I would like the output to tell me how many files were deleted. Can anybody share with me how can I get that done, or point in the correct direction?
find ./ -type f -ctime +14 |tee /tmp/find-rm | xargs rm wc -l /tmp/find-rm rm /tmp/find-rm
Or, having the right version of rm:
find ./ -type f -ctime +14 | xargs rm -v | wc -l
Or, print out number of files deleted and their total size in bytes: find ./ -type f -ctime +14 -printf "%s\n" -exec rm {} \; | awk '{s=s+$0}; END{print "Total "NR" files ("s" bytes) removed"}'
regards
- -- tomas
Uldis
participants (4)
-
Jeff Grossman
-
Steffen Kaiser
-
tomas@tuxteam.de
-
Uldis Pakuls