https://github.com/docwhat/chronic
A tool that hides output unless the command fails; now in Go!
https://github.com/docwhat/chronic
ci-tools cron golang sysadmin-tool
Last synced: 10 months ago
JSON representation
A tool that hides output unless the command fails; now in Go!
- Host: GitHub
- URL: https://github.com/docwhat/chronic
- Owner: docwhat
- License: mit
- Created: 2016-03-25T05:09:56.000Z (almost 10 years ago)
- Default Branch: main
- Last Pushed: 2024-05-16T21:08:51.000Z (over 1 year ago)
- Last Synced: 2025-03-22T04:51:15.147Z (11 months ago)
- Topics: ci-tools, cron, golang, sysadmin-tool
- Language: Shell
- Homepage:
- Size: 94.7 KB
- Stars: 31
- Watchers: 1
- Forks: 2
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# Chronic
> A tool to hide `stdout` and `stderr` when a program runs successfully (i.e., returns exit code 0).
[](https://github.com/docwhat/chronic/actions?workflow=release)
[](https://github.com/docwhat/chronic/releases)
[](https://goreportcard.com/report/github.com/docwhat/chronic)
[](https://github.com/docwhat/chronic/issues)
## About
This is a [go](https://golang.org/) based version of the classic `cronic` or `chronic` tool. [Chuck Houpt](http://habilis.net/chuck/) wrote the original [`chronic`](http://habilis.net/cronic/).
## Usage
If you've ever used `cron` to run jobs, you know that it sends an email for any output generated by the command. This is why you see `crontabs` that look like this:
```crontab
MAILTO=admin@example.com
PATH=/usr/bin:/bin
0 4 0 0 0 my-noisy-command -vF >/dev/null 2>&1
```
This is an anti-pattern:
- If you failed to get the command line correct, then you'll end up getting an email.
- If anything goes wrong, you've lost the output.
- If you log to a file, then you have to rotate that log, even if 99% of the contents are useless.
With `chronic` you don't have to worry about that anymore!
```crontab
MAILTO=admin@example.com
PATH=/usr/bin:/bin
0 4 0 0 0 chronic my-noisy-command -vF
```
Now, you'll get no emails unless `my-noisy-command` returns a non-zero exit code. If it does return a non-zero exit code, then you'll get an email that looks like this:
```email
To: admin@example.com
Subject: [CRON] chronic my-noisy-command -vF
**** command ****
[`bash` `-c` `echo "boo"; echo "emergency" 1>&2; exit 10`]
**** stdout ****
stdout: Normal output from the noisy command.
stdout: Starting messages
stdout: Normal stuff
**** stderr ****
stderr: Standard error output from the noisy command.
stderr:
stderr: [FATAL] Something went wrong!
Exited with 10
```
## Installation
### Download binaries
#### Homebrew
```sh
brew install docwhat/tap/chronic
```
#### GitHub Releases
The latest release is available on [`github.com/docwhat/chronic/releases`](https://github.com/docwhat/chronic/releases). You can download the binary for your architecture and OS there.
#### Source
```sh
go get docwhat.org/chronic
```
### Compile it yourself
You'll need to install a recent version of [Go](https://golang.org/) and set it up. You can check the `.travis.yml` file to see what version of go I'm using.
```sh
go get -u docwhat.org/chronic
```
## Developers
I love contributions! Read [CONTRIBUTING.md](CONTRIBUTING.md)!