#!/bin/sh
WORK_DIR="/where/to/work/directory"
cd $WORK_DIR || exit # In crontab, it may needs moving into work directory from default directory (home directory)
LS_FILES="$(ls -l file*)" # Wants notify this result
notifyToSlack() {
# In crontab, make sure to the curl command (or other commands) is full path.
/usr/bin/curl -X POST -H 'Content-type: application/json' \
--data "$1" \
https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX
}
notifyToSlack "{\"text\": \"\`\`\`\n$LS_FILES\n\`\`\`\"}"