Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

quiet option too quiet #19

Open
jasonblewis opened this issue Feb 22, 2017 · 2 comments
Open

quiet option too quiet #19

jasonblewis opened this issue Feb 22, 2017 · 2 comments

Comments

@jasonblewis
Copy link

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
Copy link
Author

jasonblewis commented Feb 22, 2017

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

@Alives
Copy link

Alives commented Aug 26, 2017

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants