chkcrontab icon indicating copy to clipboard operation
chkcrontab copied to clipboard

quiet option too quiet

Open jasonblewis opened this issue 8 years ago • 2 comments

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.

jasonblewis avatar Feb 22 '17 23:02 jasonblewis

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

jasonblewis avatar Feb 22 '17 23:02 jasonblewis

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)

Alives avatar Aug 26 '17 21:08 Alives