I am writing up a script to delete folders and files based on their age to be run as a scheduled task on a Synology Diskstation box running the Busybox shell. The error I keep getting appears to relate to the FIND command and its associated EXEC call on the same line, as this shell does not seem to like the \; notation I have seen suggested elsewhere on this forum, so I tried using the single-quote format at the end of the line, and still no go.
The exact error message I see when I try to run the script as root user via SSH is this: find: -exec CMD must end by ';'
Here is the script:
#!/bin/bash
# Define a timestamp function
timestamp() {
date +"%T"
}
#Run the job
[ -t 0 ] || exec >> "/volume1/homes/JSmo/Scripts/tmp/daily_purge_script.log" 2>&1
echo "Beginning folder delete task at: $(timestamp)"
find "/volume1/Synology Backup/CloudStation/jfs02/Local_copy_jfs02_f_drv/WindowsImageBackup/jfs02/Backup"/* -mtime +30 -exec rm -rf {} ';'
echo "Folder delete job completed at: $(timestamp)"
exit 0
I have looked at a number of solutions for this issue and tried many combinations of the syntax but could I have missed something simple here??
Thanks
EDIT
Thanks to eagle-eyed comment by @WalterA, I am adding this here for others. If you have this error please check your end of line (EOL) setting if using a text editor like NotePad++ on a Windows system and make sure it is set to Unix/OSX instead of DOS/Windows. See screenshot below for how to do this: