4
0

oncron.adoc 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. [#exec-cron]
  2. = Execute on schedule (cron)
  3. OliveTin can execute actions on a schedule, and uses a cron format for configuration.
  4. [source,yaml]
  5. .`config.yaml`
  6. ----
  7. actions:
  8. - title: Say hello
  9. shell: echo "Hello!"
  10. execOnCron:
  11. - "@hourly"
  12. - title: Say goodbye
  13. shell: echo "Say Goodbye"
  14. execOnCron:
  15. - "*/5 * * * *" # Every 5 minutes
  16. ----
  17. This is a fantastic website: https://cron.help/
  18. == Support for seconds in cron
  19. The default cron format for OliveTin supports the Unix/Linux format - 5 fields, with no support for seconds. This is by far the most popular format that most people are used to.
  20. If you need per-second resolution for your actions, this can be enabled in your config - meaning that your cronlines will support 6 columns. The first "new" column is seconds. For example, to execute `date` every 5 seconds;
  21. [source,yaml]
  22. .`config.yaml`
  23. ----
  24. cronSupportForSeconds: true
  25. actions:
  26. title: Execute every 5 seconds
  27. shell: date
  28. execOnCron:
  29. - "*/5 * * * * *"
  30. ----
  31. == Cron and ACLs
  32. If you have enabled ACL, cron tasks are run as the user `cron`, which means that your ACL needs to allow the cron user to execute the action. This is one possibilty:
  33. [source,yaml]
  34. .`config.yaml`
  35. ----
  36. accessControlLists:
  37. - name: "cron"
  38. matchUsernames:
  39. - cron
  40. permissions:
  41. exec: true
  42. actions:
  43. - title: Say hello
  44. shell: echo "Hello!"
  45. execOnCron:
  46. - "@hourly"
  47. acls:
  48. - "cron"
  49. ----