manage-client.cron 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # Cron for this installation — one line is enough.
  2. #
  3. # Cron is OPTIONAL here. This host is assumed not to have it, so the site drives
  4. # itself: a public page render builds gallery archives in the background (see
  5. # app/archive.php) and an admin page render runs the backup and heartbeat (see
  6. # app/manage.php). Everything below is the same work on a dependable timer
  7. # instead, and both drivers may run at the same time — the locks they share make
  8. # sure only one process ever works on a given archive.
  9. #
  10. # Two prerequisites:
  11. #
  12. # 1. set 'cron' => ['enabled' => true] in config/config.php, otherwise
  13. # cron.php refuses to run (and says so),
  14. # 2. for variant A, the worker key from data/worker-key.json.
  15. MAILTO=admin@example.org
  16. # --- A. Over the web (no shell needed; works on hosts whose "cron" is really
  17. # --- just a URL fetcher).
  18. #
  19. # One invocation drains everything outstanding: every gallery archive that is
  20. # due, the weekly backup, the hourly heartbeat. Never updates. -m 300 matches
  21. # cron.max_seconds (240 s) with room to spare; a run that finds nothing to do
  22. # costs a couple of file reads.
  23. */5 * * * * curl -s -m 300 "https://www.example.com/cron.php?key=YOUR_WORKER_KEY" >/dev/null
  24. # --- B. Over the shell. Same file, same jobs.
  25. #
  26. # Check the PHP binary with `which php`; shared hosts often want a versioned one
  27. # such as /usr/bin/php8.2. --quiet suppresses normal output — errors still go to
  28. # STDERR, and cron mails those to MAILTO, which is the point.
  29. PHP=/usr/bin/php
  30. SITE=/var/www/html/foto-portfolio
  31. */5 * * * * $PHP $SITE/cron.php --quiet
  32. # --- Optional extra: the release check.
  33. #
  34. # Not background work — a notification. Exit code 2 means "update available", and
  35. # cron reports a non-zero exit as mail, which is exactly that notification. The
  36. # backoffice checks on its own when the Maintenance page is opened, so this line
  37. # is only worth having if you want to be told without looking.
  38. 0 8 * * 1-5 $PHP $SITE/manage-client/bin/manage-client.php check --quiet
  39. # The individual jobs still have their own entry points, if you would rather give
  40. # them an explicit schedule than let cron.php decide what is due:
  41. #
  42. # */5 * * * * curl -s "https://www.example.com/worker.php?key=YOUR_WORKER_KEY"
  43. # 20 3 * * * $PHP $SITE/manage-client/bin/manage-client.php backup --trigger=cron --quiet
  44. # 7 * * * * $PHP $SITE/manage-client/bin/manage-client.php heartbeat --quiet
  45. #
  46. # Updates are deliberately installed by none of this. `update` overwrites files
  47. # while the site is live, has no rollback, and may run migrations — that belongs
  48. # in front of a human, at Admin -> Maintenance.