Skip to content

Instantly share code, notes, and snippets.

@Jimmy-Xu
Last active November 12, 2016 16:13
Show Gist options
  • Save Jimmy-Xu/917b9d85daceab414810835d26d8ed6e to your computer and use it in GitHub Desktop.
Save Jimmy-Xu/917b9d85daceab414810835d26d8ed6e to your computer and use it in GitHub Desktop.
hyper cron test

command line help

$ hyper cron

/usr/bin/hyper: "cron" requires a minimum of 1 argument.
See '/usr/bin/hyper cron --help'.

Usage:	hyper cron [OPTIONS] COMMAND [OPTIONS]

Commands:
  create                   Create a cron
  inspect                  Display detailed information on the given cron
  ls                       List all crons
  history                  Show history of the cron job
  rm                       Remove one or more crons

Run 'hyper cron COMMAND --help' for more information on a command.

create job1

$ hyper cron create --minute=/1 --hour= --name test-cron-job1 busybox ping -c 3 unknown

latest: Pulling from library/busybox
Digest: sha256:29f5d56d12684887bdfa50dcd29fc31eea4aaf4ad3bec43daf19026a7ce69912
Status: Image is up to date for busybox:latest

Cron test-cron-job1 is created.

create job2

$ hyper cron create --minute=/1 --hour= --mailto=[email protected] --name test-cron-job2 busybox ping -c 3 console.hyper.sh

latest: Pulling from library/busybox
Digest: sha256:29f5d56d12684887bdfa50dcd29fc31eea4aaf4ad3bec43daf19026a7ce69912
Status: Image is up to date for busybox:latest

Cron test-cron-job2 is created.

list job

$ hyper cron ls

Name                Schedule            Image               Command
test-cron-job1      */1 * * * *         busybox             ping -c 3 unknown
test-cron-job2      */1 * * * *         busybox             ping -c 3 console.hyper.sh

inspect job1

$ hyper cron inspect test-cron-job1

[
    {
        "Name": "test-cron-job1",
        "Schedule": "*/1 * * * *",
        "ContainerName": "",
        "Config": {
            "Hostname": "",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [],
            "Cmd": [
                "ping",
                "-c",
                "3",
                "unknown"
            ],
            "Image": "busybox",
            "Volumes": {},
            "WorkingDir": "",
            "Entrypoint": [],
            "OnBuild": [],
            "Labels": {
                "sh_hyper_instancetype": "s4"
            },
            "StopSignal": "SIGTERM"
        },
        "HostConfig": null,
        "NetConfig": null,
        "Owner": "0b1318054bfe440a97e8258ce8d92d47",
        "OwnerEmail": "",
        "SuccessCount": 2,
        "ErrorCount": 0,
        "LastSuccess": "2016-11-12T16:02:02.8Z",
        "LastError": "0001-01-01T00:00:00Z",
        "Disabled": false,
        "Tags": null
    }
]

inspect job2

$ hyper cron inspect test-cron-job2

[
    {
        "Name": "test-cron-job2",
        "Schedule": "*/1 * * * *",
        "ContainerName": "",
        "Config": {
            "Hostname": "",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [],
            "Cmd": [
                "ping",
                "-c",
                "3",
                "console.hyper.sh"
            ],
            "Image": "busybox",
            "Volumes": {},
            "WorkingDir": "",
            "Entrypoint": [],
            "OnBuild": [],
            "Labels": {
                "sh_hyper_instancetype": "s4"
            },
            "StopSignal": "SIGTERM"
        },
        "HostConfig": null,
        "NetConfig": null,
        "Owner": "0b1318054bfe440a97e8258ce8d92d47",
        "OwnerEmail": "",
        "SuccessCount": 0,
        "ErrorCount": 0,
        "LastSuccess": "0001-01-01T00:00:00Z",
        "LastError": "0001-01-01T00:00:00Z",
        "Disabled": false,
        "Tags": null
    }
]

show job1 history

$ hyper cron history test-cron-job1

Status              Name                Schedule                        Container                   Message
begin               test-cron-job1      2016-11-13 00:01:00 +0800 CST   test-cron-job1-1478966460   Job[test-cron-job1] is ready to begin
running             test-cron-job1      2016-11-13 00:01:00 +0800 CST   test-cron-job1-1478966460   Job[test-cron-job1] is running at 2016-11-12 16:01:00 +0000 UTC
success             test-cron-job1      2016-11-13 00:01:12 +0800 CST                               Job[test-cron-job1] is success to run
begin               test-cron-job1      2016-11-13 00:02:00 +0800 CST   test-cron-job1-1478966520   Job[test-cron-job1] is ready to begin
running             test-cron-job1      2016-11-13 00:02:00 +0800 CST   test-cron-job1-1478966520   Job[test-cron-job1] is running at 2016-11-12 16:02:00 +0000 UTC
success             test-cron-job1      2016-11-13 00:02:02 +0800 CST                               Job[test-cron-job1] is success to run
begin               test-cron-job1      2016-11-13 00:03:00 +0800 CST   test-cron-job1-1478966580   Job[test-cron-job1] is ready to begin
running             test-cron-job1      2016-11-13 00:03:00 +0800 CST   test-cron-job1-1478966580   Job[test-cron-job1] is running at 2016-11-12 16:03:00 +0000 UTC
success             test-cron-job1      2016-11-13 00:03:01 +0800 CST                               Job[test-cron-job1] is success to run

show job2 history

$ hyper cron history test-cron-job2

Status              Name                Schedule                        Container                   Message
begin               test-cron-job2      2016-11-13 00:02:00 +0800 CST   test-cron-job2-1478966520   Job[test-cron-job2] is ready to begin
running             test-cron-job2      2016-11-13 00:02:00 +0800 CST   test-cron-job2-1478966520   Job[test-cron-job2] is running at 2016-11-12 16:02:00 +0000 UTC
success             test-cron-job2      2016-11-13 00:02:02 +0800 CST                               Job[test-cron-job2] is success to run
begin               test-cron-job2      2016-11-13 00:03:00 +0800 CST   test-cron-job2-1478966580   Job[test-cron-job2] is ready to begin
running             test-cron-job2      2016-11-13 00:03:00 +0800 CST   test-cron-job2-1478966580   Job[test-cron-job2] is running at 2016-11-12 16:03:00 +0000 UTC
success             test-cron-job2      2016-11-13 00:03:01 +0800 CST                               Job[test-cron-job2] is success to run

delete job1

$ hyper cron rm test-cron-job1

test-cron-job1

delete job2

$ hyper cron rm test-cron-job2

test-cron-job2

list job

$ hyper cron ls

Name                Schedule            Image               Command
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment