cron.rst 3.0 KB

  1. Cron
  2. ####
  3. `Cron`__ is a program available on Unix-based operating systems that enables
  4. users to run commands and scripts at set intervals or at specific times.
  5. __
  6. Elgg's cron handler allows administrators and plugin developers to setup jobs
  7. that need to be executed at set intervals.
  8. Most common examples of cron jobs in Elgg include:
  9. * sending out queued notifications
  10. * rotating the system log in the database
  11. * collecting garbage in the database (compacting the database by removing
  12. entries that are no longer required)
  13. Currently, Elgg supports the following hooks:
  14. * ``minute`` - Run every minute
  15. * ``fiveminute`` - Run every 5 minutes
  16. * ``fifteenmin`` - Run every 15 minutes
  17. * ``halfhour`` - Run every 30 minutes
  18. * ``hourly`` - Run every hour
  19. * ``daily`` - Run every day
  20. * ``weekly`` - Run every week
  21. * ``monthly`` - Run every month
  22. * ``yearly`` - Run every year
  23. .. note::
  24. ``reboot`` cron hook has been deprecated and should not be used
  25. How does it work?
  26. =================
  27. Elgg activates its cron handler when particular cron pages are loaded.
  28. As an example, loading in a web browser
  29. activates the hourly hook. To automate this, cron jobs are setup to hit those
  30. pages at certain times. This is done by setting up a ``crontab`` which is a
  31. configuration file that determines what cron jobs do and at what interval.
  32. Installation
  33. ============
  34. The ``crontab`` needs to specify a script or command that will hit the Elgg cron pages.
  35. Two commonly available programs for this are `GET` and `wget`. You will need
  36. to determine the location of one of these on your server. Your crontab also needs
  37. to specify the location of your website.
  38. .. literalinclude:: ../examples/crontab.example
  39. In the above example, change the ``ELGG`` and ``GET`` variables to match you server setup.
  40. If you have SSH access to your Linux servers, type ``crontab -e`` and add
  41. your crontab configuration. If you already have a crontab configured, you will have to
  42. merge Elgg information into it. If you don't have SSH access, you will have to use
  43. a web-based configuration tool. This will vary depending on hosting provider.
  44. If you choose the ``wget`` utility, you might want to consider these flags:
  45. * ``--output-document`` or ``-O`` to specify the location of the concatenated output file.
  46. For example, under Debian: ``/usr/bin/wget --output-document=/dev/null``. If you don't do
  47. that, a new file will be created for each cron page load in the home directory of the cron user.
  48. * ``--spider`` to prevent the cron page from being downloaded.
  49. On Windows servers, there is a number of cron emulators available.
  50. For information on setting up cron jobs using cPanel see `cPanel Docs`__.
  51. In the ``command`` field, enter the appropriate link of the cron page.
  52. For example, for a weekly cron job, enter the command as
  53. To see if your cron jobs are running, visit Statistics > Cron in your Elgg admin
  54. panel.
  55. __