nano-run/_docs/cron.md
Alexander Baryshnikov 6fb7d88306 add ui for cron
2020-11-07 23:04:40 +08:00

1.4 KiB

Cron

Cron-like jobs allowed as part of Unit definition thanks to robfig/cron.

Example definition:

# ... unit definition above ...
cron:
    # every hour on the half hour
    - spec: 30 * * * *
    # same as above but with name to detect in UI and logs
    - spec: 30 * * * *
      name: named schedule
    # each hour with custom payload and headers
    - spec: "@hourly"
      content: |
        hello world        
      headers:
        X-Some-Header: test-header
    # each day with content from file
    - spec: "@daily"
      content_file: /path/to/content

Schema:

  • spec (required, string) - cron tab specification for the time interval. See online builder
  • name (optional, string) - name for entry to distinguish record in UI or in logs.
  • headers (optional, map string=>string) - headers that will be used in simulated request.
  • content (optional, string) - simulated request content.
  • content_file (optional, string) - simulated request content file. Has less priority than content.

Caveats:

  • Security: cron job ignores authorizations defined on unit level.
  • Enqueuing: cron job will be enqueued regardless of status of previous job.
  • Errors: if cron job can't create request (ex: content_file not available) - it will print error to log and will try again later at the next schedule.