Skip to content
This repository has been archived by the owner on May 10, 2019. It is now read-only.

aptible/docker-cron-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

aptible/cron-example

Note: this repository is deprecated. Going forward, we recommend using Supercronic instead.


Example implementation of cron jobs on Docker/Aptible

Installation and Usage

git clone https://github.com/aptible/docker-cron-example
cd docker-cron-example/
make run

The example will print "aptible/docker-cron-example" once every minute.

Including Within An App On Aptible

To include within an Aptible app, copy the following 5 body lines of the Dockerfile to your own Dockerfile:

RUN apt-get -y install rsyslog
ADD files/crontab /app/crontab
RUN crontab /app/crontab
ADD files/bin/start-cron.sh /usr/bin/start-cron.sh
RUN chmod +x /usr/bin/start-cron.sh
RUN touch /var/log/cron.log
  • Installs rsyslog http://www.rsyslog.com/
  • Copies crontab file from repo/app data to Docker and installs to user's crontab
  • Copies start-cron.sh from repo/app data to Docker
  • Adjusts permissions
  • Creates log file at /var/log/cron.log

Then, copy files to your own repo, editing files/etc/crontab with your own task, and * * * * * with your own desired job schedule.

Crash course on cron(tab) job schedules https://en.wikipedia.org/wiki/Cron#Format. Consider the asterisk (*) like a wild card. Left to rigt the argument positions are:

[Minute Arg] [Hours Arg] [Day of month arg] [Month arg] [Day of week]

To run every 5 minutes:

*/5 * * * *

To run every 5 hours:

0 */5 * * *

Finally, add an entry in your Procfile for the new cron process:

cron: /usr/bin/start-cron.sh

Copyright and License

MIT License, see LICENSE for details.

Copyright (c) 2015 Aptible and contributors.

@fancyremarker

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •