Created
February 5, 2010 13:27
-
-
Save jollyroger/295776 to your computer and use it in GitHub Desktop.
Cean incoming cronjob
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
RMFILE_LOG=`mktemp` | |
RMFILE_ERR=`mktemp` | |
RMDIR_LOG=`mktemp` | |
RMDIR_ERR=`mktemp` | |
find ~ftp/incoming -mindepth 1 -mount -type f -atime +7 -exec rm -vf {} \; >$RMFILE_LOG 2>$RMFILE_ERR | |
find ~ftp/incoming -depth -mindepth 1 -mount -type d -empty -exec rmdir -v {} \; >$RMDIR_LOG 2>$RMDIR_ERR | |
echo "Cleaning FTP incoming directory:" | |
FILE_ERRORS=`wc -l < $RMFILE_ERR` | |
echo "`wc -l <$RMFILE_LOG` file(s) to delete, $FILE_ERRORS error(s)" | |
DIR_ERRORS=`wc -l <$RMDIR_ERR` | |
echo "`wc -l <$RMDIR_LOG` empty dir(s) to delete, $DIR_ERRORS error(s)" | |
if [ "$FILE_ERRORS" -gt 0 ] ; then | |
echo | |
echo "File deletion errors:" | |
cat $RMFILE_ERR | |
fi | |
if [ "$DIR_ERRORS" -gt 0 ] ; then | |
echo | |
echo "Directory deletion errors:" | |
cat $RMDIR_ERR | |
fi | |
rm $RMFILE_LOG $RMFILE_ERR $RMDIR_LOG $RMDIR_ERR | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment