Docker-optimised cron-like functionality for Amazon ECS
crontab-like functionality using AWS ECS “run-task”
When using ECS, it is often the case that all you want out of cron is to
kick-off ECS tasks. Logging, monitoring, notifications, etc, are usually
handled by other systems. Running “real cron” for this purpose is a mix
of overkill and not enough: as the bulk of all tasks will be run
elsewhere, cron won’t receive any useful logging, and meanwhile it’s
hard to get status messages out of cron itself when debugging.
Meanwhile, the memory footprint of a full cron system is hard to
predict: because cron runs all tasks in parallel, memory requirements
can easily baloon briefly, once per minute, followed by a majority of
time spent idle. This makes memory reservation extremely inefficient.
ECSCron attempts to alleviate all of these issues:
The crontab format is meant to be roughly the same as UNIX crontab files.
Environment variables are not supported, nor is any equivalent to the
“user” column seen in system-wide crontabs. Only a single-word command
column is allowed on each line: the name of the ECS Task to run.
Leading/trailing whitespace, as well as anything after a #
, is ignored.
Example, running the “HelloWorld” task once every five minutes, between
the hours of 9am and 6pm, Monday through Friday:
# minute hour day-of-month month day-of-week task
*/5 9-17 * * 1-5 HelloWorld
see man 5 crontab
for more information on the time specfication format.
Basic Usage:
ecscron -crontab my-crontab-file -cluster my-cluster -region eu-west-1
Via Docker:
docker run \
--rm \
-v "$HOME/.aws:/root/.aws" \
-e "HOME=root" \
-v "$PWD/my-crontab-file:/etc/ecscrontab" \
wpalmer/ecscron \
-cluster my-cluster \
-region eu-west-1
Arguments:
-help
A usage message (which may be more up-to-date than this document)-async <YYYY-MM-DD HH
ss>
YYYY-MM-DD HH
ss
format. Any tasks which would have run between-timezone
option.-cluster <ECS Cluster ID>
-crontab <filename>
-debug <level number>
Debug level-dump
-dump-format <format>
json
.-dump-from <YYYY-MM-DD HH
ss>
YYYY-MM-DD HH
ss
format.-dump-until <YYYY-MM-DD HH
ss>
YYYY-MM-DD HH
ss
format.-max-pause <duration>
300s
, 5m
.-pause
-prefix <string>
-region <AWS Region Identifier>
-retry
-retry-count <number>
-simulate <true|false>
-suffix <string>
-timezone <identifier>
Signals:
SIGUSR1 is used to pause/resume ecscron