Script didn't run in schedule cron job

The below scripts were created to remove the log files contained in two directories once they are 30 days old.
find /var/tomcat-uat/logs/* -mtime +30 -exec rm {} \
find /var/tomcat-preprod/logs/* -mtime +30 -exec rm {} \

I then chmod u+x each script to make it executable.

Then I created a cron job to run each script at midnight
0 0 * * * /bin/sh /opt/scripts/; /opt/scripts/

I checked this morning to see if the logs were removed and they werenโ€™t.

cat /var/log/cron shows that it did in fact try to run.

Dec 13 00:00:01 hostname crond[6031]: (root) CMD (/bin/sh /opt/scripts/; /opt/scripts/

I manually tried to run the script and it came back with this:

find: missing argument to `-exec'

Turns out I was missing the terminator ;

Once I added that it executed successfully.

find /var/tomcat-uat/logs/* -mtime +30 -exec rm {} \;

Awesome :slight_smile: