Creating a Scheduled Job

Creating a Scheduled Job

This tutorial shows how to create a scheduled job using Chronos. We’re going to create a job that runs every 10 seconds and prints the current date.

Time Estimate

10 Minutes

Target Audience

  • Data Infrastructure Engineers
  • Data Scientists
  • Devops Engineers


  • Install Chronos
  • The job needs at least 128MB of RAM and 0.1 CPU cores available in the cluster.

Installing Chronos on DC/OS

  1. From the DC/OS web interface, go to the Services tab and click on Chronos to open its web UI.

  2. In the Chronos UI, click the New Job link to bring up the form for creating jobs.

    Chronos in the services view

  3. Fill in the following values:

    • NAME: “Date”
    • DESCRIPTION: “Prints the current date”
    • COMMAND: “/bin/date”
    • OWNER(S): Enter your email address.
    • SCHEDULE: Enter “T10S” in the “P” field

    Chronos uses ISO 8601 Interval Notation to describe job schedules. “T10S” means run this job every 10 seconds. For details, see the ISO 8601 Wikipedia article.

    Click the Create button at the top to submit the job to Chronos.

  4. Let’s verify that our job ran successfully. Run the following CLI command to view all completed tasks:

    dcos task --completed ct*

    The --completed argument includes tasks that have completed their execution. Chronos uses the prefix ct for all its tasks, so ct* filters only Chronos tasks.

    The output should look similar to this:

    NAME                    HOST        USER  STATE  ID
    ChronosTask:Date  root    F    ct:1460844479000:0:Date:
    ChronosTask:Date  root    F    ct:1460844559000:0:Date:
    ChronosTask:Date  root    F    ct:1460844569000:0:Date:
  5. To view the output of a task, copy one of the values under the ID column in the output of the previous command, and use it as the argument to dcos task log:

    dcos task log --completed ct:1460844479000:0:Date:

    The output should look similar to this, and include a line with the current date:

    Registered executor on
    Starting task ct:1460844479000:0:Date:
    Forked command at 15344
    sh -c '/bin/date'
    Sat Apr 16 22:07:59 UTC 2016
    Command exited with status 0 (pid: 15344)

Appendix: Next Steps