# 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'
    }
  }

}
```
