I'm trying to get a cron job to execute every 20 minutes that will check to make sure a directory isn't down and will output a timestamp to a text file if it is. The cron job is
*/20 * * * * if [ -d PATH_TO_FOLDER ] && [ -s "$(ls -A PATH_TO_FOLDER)" ]; then :; else timestamp=$( date +%T ) && destdir=PATH_TO_TEXT_FILE && echo "$timestamp" >> "$destdir"; fi
This will work perfectly when typed in the command window, but whenever I try to run it as a cron job I get the error:
/bin/sh: -c: line 0: unexpected EOF while looking for matching `)'
/bin/sh: -c: line 1: syntax error: unexpected end of file
I can't figure it out. Thanks for the help.