Nico Schlömer
Nico Schlömer

Reputation: 58781

Have cron email me only on actual Git errors

I'm running a cronjob that pulls a Git repository and pushes it to another location. I would like to have the cronjob run silently, but whenever something fails I would like to be notified by mail. Conveniently, cron's default setting is to send out a mail whenever the stderr buffer is not empty.

The output of git pull > /dev/null is indeed void if the local branch is up-to-date, but git push > /dev/null isn't:

$ git push > /dev/null
Everything up-to-date

This results in a mail by cron on every git push. I do not want to neglect stderr like

$ git push > /dev/null 2>&1

since I'd like to be notified of actual failures.

Any ideas?

Upvotes: 1

Views: 202

Answers (1)

Ikke
Ikke

Reputation: 101231

From the git push man page:

   -q, --quiet
       Suppress all output, including the listing of updated refs, 
       unless an error occurs. Progress is not reported to the 
       standard error stream.

There are more commands in git that let you surpress all non-error output.

Upvotes: 2

Related Questions