Bash on Synology - Delete recycle bin entries over X days old
If this is intended to be run as a command, I recommend you add a suitable shebang line.  Although the question is tagged bash, there's nothing here that isn't portable POSIX shell, so I recommend

#!/bin/sh




Is it intentional that the paths all share a common initial prefix /volume1 and that the log and error paths share a longer common prefix?  If so, encode that for easier re-use:

volume=/volume1
scriptdir=$volume/share2/SynoScripts
logpath=$scriptdir/logs/deleteOlderThanXDays.txt
errorpath=$scriptdir/errors/deleteOlderThanXDays.txt


Personally, I'd call those last two logfile and errorfile for clarity.

There's no need to quote the values in these assignments, but the values should be quoted when used later, so that we don't break the script when they change to include spaces or other significant characters.



Instead of multiple echo commands, consider using a single date with tee:

date '+%n%Y-%m-%d %T' | tee -a "$logpath" &gt;&gt;"$errorpath"


After that, we can simply redirect all output and errors:

exec &gt;&gt;"$logpath" 2&gt;&gt;"$errorpath"




When using find, prefer to group many arguments into a few commands, using + instead of \;:

find "$deletepath" \! -type d -mtime +60 -exec rm -v '{}' +
find "$deletepath" -mindepth 1 -type d -empty -exec rmdir -v '{}' +


I assume you meant to use -v consistently for both commands here.



Modified version

#!/bin/sh

volume=/volume1
scriptdir="$volume/share2/SynoScripts"

deletepath="$volume/share1/#recycle"
logpath="$scriptdir/logs/deleteOlderThanXDays.txt"
errorpath="$scriptdir/errors/deleteOlderThanXDays.txt"

# redirect all output and errors
exec &gt;&gt;"$logpath" 2&gt;&gt;"$errorpath"

# log the start time to both logs
date '+%n%Y-%m-%d %T' | tee -a "$errorpath"

# delete old non-directory files (including devices, sockets, etc)
find "$deletepath" \! -type d -mtime +60 -exec rm -v '{}' +

# delete empty directories, regardless of age
find "$deletepath" -mindepth 1 -type d -empty -exec rmdir -v '{}' +