jobs

Query and view statement backgrounding jobs.

Jobs are automatically created when a Linux command runtime exceeds your background_timing configuration setting in the CLI.

Check out the Op: Jobs article for more details.

List Jobs

Get the most recent jobs with the jobs command.

op>
jobs
ID        | STATUS    | DURATION_MS | USER              | OP_STMT
300009197 | RUNNING   | 2109        | gabe@shoreline.io | host | `sleep 5 && echo foo` | `echo bar`
300009192 | RUNNING   | 6262        | gabe@shoreline.io | pods | app="shoreline" | filter(pod_cpu_usage > 4) | `sleep 5 && echo "slept 5 on filtered pods"`
300009180 | SUCCEEDED | 6308        | gabe@shoreline.io | host | filter(cpu_usage > 6) | `sleep 5 && echo "over 6"`
300009168 | SUCCEEDED | 6113        | gabe@shoreline.io | host | timeout(10s) | `if [[ "$ACTION_INSTANCE_ID" =~ ^(i-0fc14f864dbee109a)$ ]]; then sleep 15 && echo slept15; else sleep 5 && echo done_sleeping; fi`
300009162 | SUCCEEDED | 22213       | gabe@shoreline.io | host | filter(`sleep 10 && echo "slept 10 sec"`) | `sleep 10 && echo "slept 10 sec"`
300009156 | SUCCEEDED | 25126       | gabe@shoreline.io | host | `sleep $((5 + $RANDOM % 25)) && echo hello`
300009154 | SUCCEEDED | 6109        | gabe@shoreline.io | host | `if [[ "$ACTION_INSTANCE_ID" =~ ^(i-0dad66d1996e75ad4|i-0d22fb6dea9e664d6|i-0e2d852eb4a7c0012)$ ]]; then echo "Before IT"; else sleep 5 && echo "After IT"; fi`
300009148 | SUCCEEDED | 16129       | gabe@shoreline.io | host | `sleep 15 && echo "slept 15 secs"`
300009015 | SUCCEEDED | 31142       | gabe@shoreline.io | host | `sleep 30 && echo "Complete"`
300008958 | SUCCEEDED | 31141       | gabe@shoreline.io | host | `sleep 30 && echo "Complete"`

By default, jobs returns the ten most recent jobs.

Limit

Set the number of jobs returned using the limit parameter.

op>
jobs | limit = 20
ID   | STATUS          | DURATION_MS | USER                                | OP_STMT
2896 | SUCCEEDED       | 11253       | gabe@shoreline.io                   | containers | limit = 5 | timeout(10s) | `if [[ "$ACTION_CONTAINER_NAME" =~ (bookstore) ]]; then sleep 15; else sleep 5 && echo done; fi`
2756 | SUCCEEDED       | 11237       | gabe@shoreline.io                   | containers | limit = 5 | timeout(10s) | `if [[ "$ACTION_CONTAINER_NAME" =~ (bookstore) ]]; then sleep 15; else sleep 5 && echo done; fi`
2507 | SUCCEEDED       | 4242        | gabe@shoreline.io                   | containers | limit = 5 | timeout(10s) | `sleep 3 && echo done`
2493 | SUCCEEDED       | 3223        | gabe@shoreline.io                   | containers | limit = 5 | timeout(10s) | `sleep 2 && echo done`
2488 | SUCCEEDED       | 6223        | gabe@shoreline.io                   | containers | limit = 5 | timeout(10s) | `sleep 5 && echo done`
2418 | SUCCEEDED       | 11240       | gabe@shoreline.io                   | containers | limit = 5 | timeout(10s) | `if [[ "$ACTION_CONTAINER_NAME" =~ (bookstore) ]]; then sleep 15 && echo slept 15; else sleep 5 && echo done_sleeping; fi`
2347 | SUCCEEDED       | 6248        | gabe@shoreline.io                   | containers | limit = 5 | timeout(10s) | `if [[ "$ACTION_CONTAINER_NAME" =~ ^(bookstore)$ ]]; then sleep 15 && echo slept 15; else sleep 5 && echo done_sleeping; fi`
2127 | SUCCEEDED       | 6357        | integration-test-admin@shoreline.io | host | filter(cpu_usage > 1) | `sleep 5 && echo hello`
2096 | SUCCEEDED       | 56313       | integration-test-admin@shoreline.io | host | .pod | app="shoreline" | `sleep $((5 + $RANDOM % 25)) && echo "Linux cmd 1"` | `sleep $((5 + $RANDOM % 25)) && echo "Linux cmd 2"`
2086 | SUCCEEDED       | 11151       | integration-test-admin@shoreline.io | host | timeout(10s) | `if [[ "$ACTION_INSTANCE_ID" =~ ^(i-0e95acb5362fedaf5)$ ]]; then sleep 15 && echo done; else sleep 5 && echo done_sleeping; fi`
2056 | PARTIAL_FAILURE | 35085       | integration-test-admin@shoreline.io | host | timeout(20s) | `sleep 15; echo done`
2049 | SUCCEEDED       | 11115       | integration-test-admin@shoreline.io | host | `sleep 10 && echo world`
2037 | SUCCEEDED       | 11125       | integration-test-admin@shoreline.io | host | `sleep 10; echo "done statement 2"`
2036 | SUCCEEDED       | 6115        | integration-test-admin@shoreline.io | host | `sleep 5; echo " done statement 1"`
2030 | SUCCEEDED       | 6571        | gabe@shoreline.io                   | container | app="bookstore" | timeout(10s) | `if [[ "$ACTION_CONTAINER_NAME" =~ ^(bookstore)$ ]]; then sleep 15 && echo slept 15; else sleep 5 && echo done_sleeping; fi`
2026 | SUCCEEDED       | 12268       | integration-test-admin@shoreline.io | host | filter(`sleep 5 && echo hello`) | `sleep 5 && echo world`
2016 | SUCCEEDED       | 6122        | integration-test-admin@shoreline.io | host | `if [[ "$ACTION_INSTANCE_ID" =~ ^(i-0d66949e63d67dd3e)$ ]]; then echo done; else sleep 5 && echo done_sleeping; fi`
2011 | SUCCEEDED       | 6139        | integration-test-admin@shoreline.io | host | `sleep 5; ls`

Status

Filter jobs by status with the status parameter.

Valid values:

  • succeeded: The job was successful.
  • failed: The job failed.
  • running: The job is active.
  • partial_failure: The job succeeded on some, but not all, targeted Resources.

For example, consider the following list of recent jobs.

op>
jobs
ID   | STATUS          | DURATION_MS  | USER                                 | OP_STMT
3524 | RUNNING         | 1.010232e+06 | gabe@shoreline.io                    | host | limit = 3 | timeout(3600s) | `long-running-script.sh`
2418 | SUCCEEDED       | 11240        | gabe@shoreline.io                    | containers | limit = 5 | timeout(10s) | `if [[ "$ACTION_CONTAINER_NAME" =~ (bookstore) ]]; then sleep 15 && echo slept 15; else sleep 5 && echo done_sleeping; fi`
2347 | SUCCEEDED       | 6248         | gabe@shoreline.io                    | containers | limit = 5 | timeout(10s) | `if [[ "$ACTION_CONTAINER_NAME" =~ ^(bookstore)$ ]]; then sleep 15 && echo slept 15; else sleep 5 && echo done_sleeping; fi`
2086 | SUCCEEDED       | 11151        | integration-test-admin@shoreline.io  | host | timeout(10s) | `if [[ "$ACTION_INSTANCE_ID" =~ ^(i-0e95acb5362fedaf5)$ ]]; then sleep 15 && echo done; else sleep 5 && echo done_sleeping; fi`
2056 | PARTIAL_FAILURE | 35085        | integration-test-admin@shoreline.io  | host | timeout(20s) | `sleep 15; echo done`
2049 | SUCCEEDED       | 11115        | integration-test-admin@shoreline.io  | host | `sleep 10 && echo world`
2037 | SUCCEEDED       | 11125        | integration-test-admin@shoreline.io  | host | `sleep 10; echo "done statement 2"`

Get only the successful jobs with status = "succeeded":

op>
jobs | status = "succeeded"
ID   | STATUS          | DURATION_MS  | USER                                 | OP_STMT
2418 | SUCCEEDED       | 11240        | gabe@shoreline.io                    | containers | limit = 5 | timeout(10s) | `if [[ "$ACTION_CONTAINER_NAME" =~ (bookstore) ]]; then sleep 15 && echo slept 15; else sleep 5 && echo done_sleeping; fi`
2347 | SUCCEEDED       | 6248         | gabe@shoreline.io                    | containers | limit = 5 | timeout(10s) | `if [[ "$ACTION_CONTAINER_NAME" =~ ^(bookstore)$ ]]; then sleep 15 && echo slept 15; else sleep 5 && echo done_sleeping; fi`
2086 | SUCCEEDED       | 11151        | integration-test-admin@shoreline.io  | host | timeout(10s) | `if [[ "$ACTION_INSTANCE_ID" =~ ^(i-0e95acb5362fedaf5)$ ]]; then sleep 15 && echo done; else sleep 5 && echo done_sleeping; fi`
2049 | SUCCEEDED       | 11115        | integration-test-admin@shoreline.io  | host | `sleep 10 && echo world`
2037 | SUCCEEDED       | 11125        | integration-test-admin@shoreline.io  | host | `sleep 10; echo "done statement 2"`

Or, get just the running jobs:

op>
jobs | status="running"
ID   | STATUS          | DURATION_MS  | USER                                 | OP_STMT
3524 | RUNNING         | 1.010232e+06 | gabe@shoreline.io                    | host | limit = 3 | timeout(3600s) | `long-running-script.sh`

User

Filter jobs by the executing user with the user parameter.

op>
jobs | user = "gabe@shoreline.io"
ID   | STATUS          | DURATION_MS  | USER                                 | OP_STMT
3524 | RUNNING         | 1.010232e+06 | gabe@shoreline.io                    | host | limit = 3 | timeout(3600s) | `long-running-script.sh`
2418 | SUCCEEDED       | 11240        | gabe@shoreline.io                    | containers | limit = 5 | timeout(10s) | `if [[ "$ACTION_CONTAINER_NAME" =~ (bookstore) ]]; then sleep 15 && echo slept 15; else sleep 5 && echo done_sleeping; fi`
2347 | SUCCEEDED       | 6248         | gabe@shoreline.io                    | containers | limit = 5 | timeout(10s) | `if [[ "$ACTION_CONTAINER_NAME" =~ ^(bookstore)$ ]]; then sleep 15 && echo slept 15; else sleep 5 && echo done_sleeping; fi`
2086 | SUCCEEDED       | 11151        | integration-test-admin@shoreline.io  | host | timeout(10s) | `if [[ "$ACTION_INSTANCE_ID" =~ ^(i-0e95acb5362fedaf5)$ ]]; then sleep 15 && echo done; else sleep 5 && echo done_sleeping; fi`
2056 | PARTIAL_FAILURE | 35085        | integration-test-admin@shoreline.io  | host | timeout(20s) | `sleep 15; echo done`
2049 | SUCCEEDED       | 11115        | integration-test-admin@shoreline.io  | host | `sleep 10 && echo world`
2037 | SUCCEEDED       | 11125        | integration-test-admin@shoreline.io  | host | `sleep 10; echo "done statement 2"`
op>
jobs | user = "integration-test-admin@shoreline.io"
ID   | STATUS          | DURATION_MS  | USER                                 | OP_STMT
2086 | SUCCEEDED       | 11151        | integration-test-admin@shoreline.io  | host | timeout(10s) | `if [[ "$ACTION_INSTANCE_ID" =~ ^(i-0e95acb5362fedaf5)$ ]]; then sleep 15 && echo done; else sleep 5 && echo done_sleeping; fi`
2056 | PARTIAL_FAILURE | 35085        | integration-test-admin@shoreline.io  | host | timeout(20s) | `sleep 15; echo done`
2049 | SUCCEEDED       | 11115        | integration-test-admin@shoreline.io  | host | `sleep 10 && echo world`
2037 | SUCCEEDED       | 11125        | integration-test-admin@shoreline.io  | host | `sleep 10; echo "done statement 2"`

Filter Chaining

Combine multiple job filters by chaining them together using pipes.

For example, get all jobs executed by a specific user and status:

op>
jobs | user = "gabe@shoreline.io" | status = "running"
ID   | STATUS   | DURATION_MS  | USER              | OP_STMT
3524 | RUNNING  | 1.010232e+06 | gabe@shoreline.io | host | limit = 3 | timeout(3600s) | `long-running-script.sh`

Job Details

Get the details of a specific job with the jobs | id = <job_id> command.

op>
jobs | id = 300009192
ID | NAME                | STATUS    | TOTAL_DURATION_MS | EXECUTION_TIME_MS | REQUEST
65 | i-00f9034231ac2bec0 | COMPLETED | 135               | 6                 | metric_query
65 | i-00f9034231ac2bec0 | COMPLETED | 6225              | 6028              | sleep 5 && echo "slept 5 on filtered pods"
66 | i-0ba70a62ee3b38683 | COMPLETED | 135               | 5                 | metric_query
66 | i-0ba70a62ee3b38683 | COMPLETED | 6229              | 6026              | sleep 5 && echo "slept 5 on filtered pods"
67 | i-00e36a7da4ff269b1 | COMPLETED | 135               | 5                 | metric_query
67 | i-00e36a7da4ff269b1 | COMPLETED | 6223              | 6026              | sleep 5 && echo "slept 5 on filtered pods"

ID  | TYPE      | NAME                                 | REGION    | AZ         | STATUS | STDOUT
79  | CONTAINER | alpha-cust.shoreline-r4ncg.shoreline | us-west-2 | us-west-2a |   0    | slept 5 on filtered pods
93  | CONTAINER | alpha-cust.shoreline-7d25h.shoreline | us-west-2 | us-west-2c |   0    | slept 5 on filtered pods
101 | CONTAINER | alpha-cust.shoreline-drwch.shoreline | us-west-2 | us-west-2b |   0    | slept 5 on filtered pods

The first table shows each Agent-installed Resource on which the command was executed, along with each execution step and its corresponding request. For example, we can see that the Metric query filter only took a few milliseconds, while the intentionally-lengthy sleep command took much longer.

The second table shows the standard Op statement table with the actual Resources targeted by the Resource query, on which the command was executed. We see the container Resources and the stdout returned by the above example.