Skip to content

Instantly share code, notes, and snippets.

@multidis
Last active September 15, 2021 12:24
Show Gist options
  • Select an option

  • Save multidis/475e05fd6cdc63f31d53 to your computer and use it in GitHub Desktop.

Select an option

Save multidis/475e05fd6cdc63f31d53 to your computer and use it in GitHub Desktop.

Revisions

  1. multidis revised this gist Apr 18, 2015. 2 changed files with 6 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions cronrun.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    #!/bin/sh
    cd /home/testing
    timeout 10 python /home/testing/testcron.py >>/var/log/crontesting.log 2>&1
    3 changes: 3 additions & 0 deletions testcron.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    #!/usr/bin/env python
    import datetime
    print "Cron job has run at %s" %datetime.datetime.now()
  2. multidis revised this gist Apr 18, 2015. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions mycrontab
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

    # Jobs:
    # m h dom mon dow command
    * * * * * /home/testing/cronrun.sh
  3. multidis created this gist Apr 18, 2015.
    40 changes: 40 additions & 0 deletions Dockerfile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,40 @@
    # phusion baseimage initiates cron properly

    # Use phusion/baseimage as base image. To make your builds reproducible, make
    # sure you lock down to a specific version, not to `latest`!
    # See https://github.com/phusion/baseimage-docker/blob/master/Changelog.md for
    # a list of version numbers.
    FROM phusion/baseimage:0.9.16

    # Use baseimage-docker's init system.
    CMD ["/sbin/my_init"]

    # install Ubuntu packages and other items as needed
    # using python example here
    # install dependencies from Ubuntu repositories
    RUN apt-get -qq update && \
    apt-get upgrade -y -o Dpkg::Options::="--force-confdef" -o DPkg::Options::="--force-confold" && \
    apt-get install -y -q \
    git \
    build-essential \
    python \
    python-yaml \
    python-dev \
    python-setuptools \
    python-pip \
    && \
    apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

    # install python dependencies
    RUN easy_install -U setuptools && \
    pip install -U pip

    # add cron scripts and make executable
    RUN mkdir /home/testing
    ADD testcron.py /home/testing/testcron.py
    ADD cronrun.sh /home/testing/cronrun.sh
    RUN chmod +x /home/testing/cronrun.sh

    # cron schedule
    ADD mycrontab /home/testing/mycrontab
    RUN crontab /home/testing/mycrontab