diff --git a/docs/administration/recent_activity/recent_activity.md b/docs/administration/recent_activity/recent_activity.md index 3367c9ecf5..108149aee8 100644 --- a/docs/administration/recent_activity/recent_activity.md +++ b/docs/administration/recent_activity/recent_activity.md @@ -31,11 +31,10 @@ ibexa: truncate_after_days: 15 ``` -To automate a regular truncation, the command `ibexa:activity-log:truncate` must be added to a crontab. +To automate a regular truncation, the command `ibexa:activity-log:truncate` must be added to a cron job. To minimize the number of entries to delete, it's recommended to execute the command more than one time a day. -For every exact hour, the cronjob line is: -`0 * * * * cd [path-to-ibexa]; php bin/console ibexa:activity-log:truncate --quiet --env=prod` +For more information, see [Additional cron jobs and advanced usage](install_ibexa_dxp.md#additional-cron-jobs-and-advanced-usage). ### Display limit diff --git a/docs/cdp/cdp_data_export_schedule.md b/docs/cdp/cdp_data_export_schedule.md index 49c94078e5..268554a0e7 100644 --- a/docs/cdp/cdp_data_export_schedule.md +++ b/docs/cdp/cdp_data_export_schedule.md @@ -66,3 +66,7 @@ php bin/console ibexa:cdp:stream-product-data --help ```bash php bin/console ibexa:cdp:stream-content-data --help ``` + +The configuration is executed by `ibexa:cron:run` command which must be configured as a cron job. + +For more information, see [Scheduling cron jobs](install_ibexa_dxp.md#scheduling-cron-jobs). diff --git a/docs/content_management/url_management/url_management.md b/docs/content_management/url_management/url_management.md index 20af85356b..ae0c385e63 100644 --- a/docs/content_management/url_management/url_management.md +++ b/docs/content_management/url_management/url_management.md @@ -37,24 +37,7 @@ The following protocols are currently supported: To enable automatic URL validation, set up cron to run the `ibexa:check-urls` command periodically. -For example, to check links every week, add the following script: - -```bash -echo '0 0 * * 0 cd [path-to-ibexa]; php bin/console ibexa:check-urls --quiet --env=prod' > ezp_cron.txt -``` - -Next, append the new cron to user's crontab without destroying existing crons. -Assuming that the web server user data is www-data: - -```bash -crontab -u www-data -l|cat - ezp_cron.txt | crontab -u www-data - -``` - -Finally, remove the temporary file: - -```bash -rm ezp_cron.txt -``` +For more information, see [Additional cron jobs and advanced usage](install_ibexa_dxp.md#additional-cron-jobs-and-advanced-usage). ### Configuration diff --git a/docs/getting_started/install_ibexa_dxp.md b/docs/getting_started/install_ibexa_dxp.md index 8e6d13b984..dc267bd6b3 100644 --- a/docs/getting_started/install_ibexa_dxp.md +++ b/docs/getting_started/install_ibexa_dxp.md @@ -395,7 +395,6 @@ Prepare a [virtual host configuration](https://en.wikipedia.org/wiki/Virtual_hos You can use [this example vhost file](https://raw.githubusercontent.com/ibexa/post-install/main/resources/templates/nginx/vhost.template) and modify it to fit your project. You also need the `ibexa_params.d` files that should reside in a subdirectory below where the main file is, [as is shown here](https://github.com/ibexa/post-install/tree/5.0/resources/templates/nginx). - Specify `//public` as the `root`, or ensure `BASEDIR` is set in the environment. Ensure `APP_ENV` is set to `prod` or `dev` in the environment, depending on the environment that you're configuring, and uncomment the line that starts with `#if[APP_ENV`. @@ -412,30 +411,105 @@ You should see the welcome page. See the [Security checklist](security_checklist.md) for a list of security-related issues you should take care of before going live with a project. -### Enable Date-based Publisher +### Scheduling cron jobs + +The `ibexa:cron:run` command executes all service commands tagged `ibexa.cron.job`. +It should be scheduled to run every minute. + +The following example creates a temporary file with the crontab entry and appends it to the existing crontab for the web server user (`www-data`): + +```bash +echo '* * * * * cd ; php bin/console ibexa:cron:run --quiet --env=prod' > ibexa_cron.txt +crontab -u www-data -l | cat - ibexa_cron.txt | crontab -u www-data - +rm ibexa_cron.txt +``` + +For [Scheduled content publications]([[= user_doc =]]/content_management/schedule_publishing/), the `ibexa:scheduled:run` command is tagged with `ibexa.cron.job` and, by default, runs every minute (`* * * * *`). +If needed, you can redefine this service to set up another frequency. + +The [CDP data export schedule](cdp_data_export_schedule.md) dynamically creates services tagged with `ibexa.cron.job`. + +You can add other commands to cron by either: + +- Adding their own scheduling line to the crontab +- Tagging their service with `ibexa.cron.job` + +#### Additional cron jobs and advanced usage + +To use [Link manager](url_management.md), schedule the URL validation command `ibexa:check-urls`. + +To [control the recent activity log size](recent_activity.md#log-retention), schedule the `ibexa:activity-log:truncate` command. + +The following example schedules these commands separately: -To enable delayed publishing of Content using the Date-based Publisher, you must set up cron to run the `bin/console ibexa:scheduled:run` command periodically. +- `ibexa:cron:run` every minute +- `ibexa:check-urls` every week (on Sunday at midnight) +- `ibexa:activity-log:truncate` every hour (at minute 0) -For example, to check for publishing every minute, add the following script: +This shell script creates a temporary file with the job lines, then replaces the existing crontab for the web server user: -`echo '* * * * * cd [path-to-ibexa-dxp]; php bin/console ibexa:cron:run --quiet --env=prod' > ezp_cron.txt` +```bash +echo '* * * * * cd ; php bin/console ibexa:cron:run --quiet --env=prod' > ibexa_cron.txt +echo '0 0 * * 0 cd ; php bin/console ibexa:check-urls --quiet --env=prod' >> ibexa_cron.txt +echo '0 * * * * cd ; php bin/console ibexa:activity-log:truncate --quiet --env=prod' >> ibexa_cron.txt +crontab -u www-data ibexa_cron.txt +rm ibexa_cron.txt +``` + +The following alternative example uses service tagging to schedule these commands. +It also changes the `ibexa:scheduled:run` frequency to every five minutes. + +Add the following to `config/services.yaml`: + +``` +services: + #… + + Ibexa\Bundle\Scheduler\Command\ScheduledRunCommand: + tags: + - { name: ibexa.cron.job, schedule: '*/5 * * * *' } + + Ibexa\Bundle\Core\Command\CheckURLsCommand: + arguments: + $urlChecker: '@Ibexa\Bundle\Core\URLChecker\URLChecker' + tags: + - { name: ibexa.cron.job, schedule: '0 0 * * 0' } + + Ibexa\Bundle\ActivityLog\Command\TruncateLogCommand: + tags: + - { name: ibexa.cron.job, schedule: '0 * * * *' } +``` -For 5-minute intervals: +The `ibexa.cron.job` tag accepts the following options: -`echo '*/5 * * * * cd [path-to-ibexa-dxp]; php bin/console ibexa:cron:run --quiet --env=prod' > ezp_cron.txt` +- `schedule`: A cron expression representing the period or interval. +- `options`: Arguments passed to the command. Note that `--env` and `--siteaccess` are inherited from `ibexa:cron:run`. +- `category`: Commands can be grouped into categories, and a category can be passed with `ibexa:cron:run --category=`. By default, the `default` category is used. + For example, it can be used to set different jobs and `schedule` for different [SiteAccesses](multisite_configuration.md). +- `priority`: Defines the order in which `ibexa:cron:run` executes commands that are due. -Next, append the new cron to user's crontab without destroying existing crons. -Assuming the web server user data is `www-data`: +You can list the command services schedule by this tag with the following command: -`crontab -u www-data -l|cat - ezp_cron.txt | crontab -u www-data -` +```bash +php bin/console debug:container --tag=ibexa.cron.job +``` -Finally, remove the temporary file: +The following example shows how to set up a different schedule for a specific SiteAccess with a category. -`rm ezp_cron.txt` +This command schedules `ibexa:cron:run` for the SiteAccess `minor_website` and the job category `minor_website`: -### Enable the Link manager +```bash +(crontab -u www-data -l; echo '* * * * * cd ; php bin/console ibexa:cron:run --quiet --env=prod --siteaccess=minor_website --category=minor_website') | crontab -u www-data - +``` -To make use of the [Link Manager](url_management.md#enabling-automatic-url-validation). +Then, `ibexa:scheduled:run` can run on this SiteAccess at a different frequency from the default: + +``` + Ibexa\Bundle\Scheduler\Command\ScheduledRunCommand: + tags: + - { name: ibexa.cron.job, schedule: '* * * * *' } + - { name: ibexa.cron.job, schedule: '*/5 * * * *', category: 'minor_website' } +``` ### Enable discount re-indexing [[% include 'snippets/commerce_badge.md' %]]