Skip to content

Latest commit

 

History

History
49 lines (32 loc) · 1.12 KB

README.md

File metadata and controls

49 lines (32 loc) · 1.12 KB

cron-runtime

Simple utility to run commands by a cron schedule. It is useful for having cron like functionality in Docker containers.

Key features

  • Extended cron format support (thanks to robfig/cron)
  • Graceful shutdown with timeout
  • Runs in foreground (useful for Docker containers)

Installation

go install github.com/abler98/cron-runtime@latest

Syntax

Usage: cron-runtime [options] <cron expression> -- program [parameters...]

Options

  • -h: Show help message
  • -once: Run command once and exit
  • -kill-timeout <seconds>: Timeout for killing the command (default: 0 - no timeout)
  • -debug: Print debug messages

Example

# print "Hello, world!" every 5 minutes
cron-runtime "*/5 * * * *" -- echo "Hello, world!"

Usage in Docker

FROM golang:1.21-alpine AS cron-runtime

RUN go install github.com/abler98/cron-runtime@latest

FROM my-laravel-app

COPY --from=cron-runtime /go/bin/cron-runtime /usr/bin/cron-runtime

ENTRYPOINT ["cron-runtime", "-kill-timeout=60", "* * * * *", "--", "php", "artisan", "schedule:run"]