Skip to content

cron job from cron/1.3.0

This BOSH job creates a customized crontab, and installs it for the host OS's cron process to manage. Upon stopping, it should clean up after itself

Github source: 0dd31b5 or master branch

Properties

cron

entries

A list of key-value objects representing cron entries. Each entry must contain properties for ‘minute’, ‘hour’, ‘day’, ‘month’, ‘wday’, ‘user’, and ‘command’. These properties are directly injected into the crontab, and should follow cron syntax conventions.

If command is specified, that path is executed by cron and must already exist. If script is specified, the contents of that key are written out to disk and executed by cron.

If command and script are specified for the same entry, the contents of script will be executed, and command ignored

If lock is specified, the cronjob will be wrapped by flock(1) -n ensuring only one instance runs at a time.

If log is specified, the cronjob’s stdout and stderr will be redirected to specified path. those scripts are recommend to start with “set -x”.

If a hash of variables is specified, the cronjob will run with those environment variables.

Example
- command: /var/vcap/packages/mypackage/bin/myhourlyscript
  day: '*'
  hour: '*'
  lock: /var/vcap/sys/run/cron/myhourly.lock
  log: /var/vcap/sys/log/cron/myhourlyscrip.log
  minute: 0
  month: '*'
  script:
    contents: |+
      #!/bin/bash

      touch /tmp/i-am-running
    name: touch.sh
  user: root
  wday: '*'

variables

A key-value map of environment variables that should be set in the crontab

Example
HOME: /home/vcap
PATH: /var/vcap/package/mypackage/bin:/bin:/sbin:/usr/sbin:/usr/bin:/usr/local/bin

Templates

Templates are rendered and placed onto corresponding instances during the deployment process. This job's templates will be placed into /var/vcap/jobs/cron/ directory (learn more).

  • bin/cron_ctl (from bin/cron_ctl)
  • bin/monit_debugger (from bin/monit_debugger)
  • bin/setup_crontab (from bin/setup_crontab.erb)
  • bin/sleeper (from bin/sleeper)
  • data/properties.sh (from data/properties.sh.erb)
  • helpers/ctl_setup.sh (from helpers/ctl_setup.sh)
  • helpers/ctl_utils.sh (from helpers/ctl_utils.sh)

Packages

Packages are compiled and placed onto corresponding instances during the deployment process. Packages will be placed into /var/vcap/packages/ directory.

This job relies on no runtime packages.