chkcrontab
chkcrontab copied to clipboard
quiet option too quiet
It would be great if there was a quiet option that would emit nothing if no error or warnings were found, but would emit the warning or error if one is found.
Use case is to have chkcrontab running from a file in /etc/cron.d on a regular basis so any errors that slipped in will be picked up and emailed to root.
so a cron entry like:
5 * * * * root for i in /etc/cron.d/*; do /usr/local/bin/chkcrontab -q $i ; done
would only email the user if an error was detected.
ps, you can work around this by doing something like
5 * * * * root for i in /etc/cron.d/*; do if ! /usr/local/bin/chkcrontab -q $i ; then /usr/local/bin/chkcrontab $i ; fi; done
I'd like no output unless there's an error as well.
#!/bin/bash
while IFS= read -r -d '' file
do
if ! status=$(/usr/local/bin/chkcrontab "$file" 2>&1); then
echo "$status"
fi
done < <(find /etc/cron.d /var/spool/cron/crontabs -type f -mmin 2 -print0)