Giter Club home page Giter Club logo

cf-cron-python's Introduction

Running A Python Cron Job on Cloud Foundry

This repository demonstrates scheduling a Python script on Cloud Foundry using a traditional crontab within a Docker image.

Traditional cron daemons need to run as root and have opinionated defaults for logging and error notifications. This makes them unsuitable for running in a containerized environment like Docker. And Docker is sometimes preferable to Cloud Foundry buildpacks. So, instead of a system cron daemon, we're using supercronic to run the cron tab.

How it works

This application uses supercronic on the crontab file, all within a Docker container. The crontab file specifies a single cron job, which is to execute main.py every 10 seconds. You could add additional jobs by adding new lines to crontab that specify a schedule and command.

Since some Python tasks are a bit more complicated than printing datetime.datetime.now(), this example also demos installation of a few debian dependencies and just one python requirement.

The image based on this Dockerfile can be found on DockerHub, so you can push the app to cloud.gov with

cf push cf-cron-python --docker-image csmcallister/cf-cron-python

Then, after it builds, use cf logs cf-cron-python --recent to see the print messages.

cf-cron-python's People

Contributors

csmcallister avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

thekibiru03

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.