# Job

## Cron

The new min jobs per day for cortex will be 1 every 10 seconds (8640). This allows up to 6 \* \* \* \* \* type cron jobs until limits are reached. This is a minimum allowance which supercedes the maximum allowance if it is lower. Effectively Math.max( min, env max). The new default is also 8640 per day.x

### Job

```javascript
@job('1 * * * *', {
  name: 'update_check',
  weight: 5
})
updateCheck({ context, runtime }) {

  console.log(runtime.configuration.cron, script.principal.email)

}
```

#### @job(options)

*Arguments*

* `options` { Object } Options object
  * `name` { String }
  * `type` { String }
  * `principal` { String }
  * `environment` { String = *"\*"* }
  * `weight` { Number = *0* }
  * `cron` { String } [Cron job syntax](https://en.wikipedia.org/wiki/Cron)

#### @job(cron, options)

*Arguments*

* `cron` { String } [Cron job syntax](https://en.wikipedia.org/wiki/Cron)
* `options` { Object } Options object
  * `name` { String }
  * `type` { String }
  * `principal` { String }
  * `environment` { String = *"\*"* }
  * `weight` { Number = *0* }

#### @job(cron, principal, options)

*Arguments*

* `cron` { String } [Cron job syntax](https://en.wikipedia.org/wiki/Cron)
* `principal` { String }
* `options` { Object } Options object
  * `name` { String }
  * `type` { String }
  * `environment` { String = *"\*"* }
  * `weight` { Number = *0* }

#### Method Options

* `methodOptions` { Object } Options passed to the method
  * `runtime` { Object }
    * `name` { String }
    * `type` { String }
    * `principal` { String }
    * `environment` { String = *"\*"* }
    * `weight` { Number = *0* }
    * `configuration` { Object }
      * `cron` { String }
    * `metadata` { Object }
      * `resource` { String }
      * `className` { String }
      * `methodName` { String }
      * `static` { Boolean }
      * `loc` { Object }
        * `line` { String }
        * `column` { String }

## Examples

Override Jobs

```javascript
const { job } = require('decorators')

class JobTest {

  @job('*/1 * * * *', { name: 'hello_job' })
  maintenance({ context, runtime }) {
    return {
      context,
      runtime,
      value: 'hello from job'
    }
  }

}

class JobTestOverride {
  // JobTest hello_job will be overwritten by this new job  
  @job('*/2 * * * *', { name: 'hello_job', weight: 1 })
  maintenance({ context, runtime }) {
    return {
      context,
      runtime,
      value: 'hello from overwritten job'
    }
  }

}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.medable.com/cortex-api/decorators/static/job.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
