I have created a script for my Synology NAS which checks the video folder to see if there are files older than seven days. However it is not deleting, the error message I am getting is
sh: of: unknown operand
Here is my script:
echo "------- SCRIPT START -------"
sleep 2
if test 'find /volume1/Media/ -mtime +7'
then
sleep 2
echo "Deleting files"
-exec rm -r {} \;
sleep 2
echo "Deleted files"
else
echo "There are no files to delete"
fi
a short script to just remove files older than 7 days:
dir="/volume1/Media"
days=7
echo -n "removing files in $dir that are older than $days days: "
find "$dir" -mtime +$days -type f -exec echo {} \; -exec rm {} \; | wc -l