Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/meowgorithm/babycron

Run a single cron job in the foreground. Works well in Docker.
https://github.com/meowgorithm/babycron

cli cron crontab docker

Last synced: about 2 months ago
JSON representation

Run a single cron job in the foreground. Works well in Docker.

Awesome Lists containing this project

README

        

Babycron
========

[![Build Status](https://github.com/meowgorithm/babycron/workflows/build/badge.svg)](https://github.com/meowgorithm/babycron/actions)

Run a single cron job in the foreground, sending output to stdout. Works well
in Docker.

## Usage

Pass two arguments: the cron schedule and a string of the task to run.

```bash
# Run a script every minute
babycron '*/1 * * * *' 'sh path/to/script.sh'

# Run a script on start, and then again every six hours
babycron --run-on-start '0 */6 * * *' 'sh path/to/script.sh'

# Gzip and backup a Redis DB every day at midnight
babycron '0 0 * * *' 'cat /data/dump.rdb | gzip | pipedream -b backups -p backup.rdb.gz'
```

Note that if you’re running a script you *must* include the interpreter in the
second argument (i.e. `sh` or `/bin/sh`), regardless if you have a `#!` and
executable permissions. Babycron will search your `PATH`, so things like `bash`
or `sh`, without the full path to the interpreter, is usually fine.

In Docker:

```docker
ENTRYPOINT [ "babycron", "* * * * *", "sh path/to/script.sh" ]
```

Output and errors are sent to stdout, so they'll appear in your Docker logs.

## Installation

macOS and Linux users can use Homebrew:

```bash
brew tap meowgorithm && brew install babycron
```

Additional binaries can be found on the [releases](https://github.com/meowgorithm/babycron/releases) page (Linux x86_64/ARM, macOS x86_64, Windows x86_64/i386).

Or just use `go get`:

```bash
go get github.com/meowgoritm/babycron
```

## License

MIT