Create cronjob in the customer menu (Plesk)
In the customer menu, you can create so-called cronjobs under the menu item "Scheduled tasks" for the automatic execution of tasks.
You can access the "Scheduled tasks" either via the sidebar or the domain settings in the dashboard.
For example, if you want to set up a cronjob to run the TYPO3 scheduler, you can set it up as shown in the picture.
Available PHP-CLI versions
If the script must be executed with a specific PHP version, e.g. the TYPO3 scheduler, the following PHP versions are available:
- /opt/alt/php84/usr/bin/php
- /opt/alt/php83/usr/bin/php
- /opt/alt/php82/usr/bin/php
- /opt/alt/php81/usr/bin/php
- /opt/alt/php80/usr/bin/php
- /opt/alt/php74/usr/bin/php
- /opt/alt/php73/usr/bin/php
- /opt/alt/php72/usr/bin/php
- /opt/alt/php71/usr/bin/php
- /opt/alt/php70/usr/bin/php
- /opt/alt/php56/usr/bin/php
- /opt/alt/php55/usr/bin/php
- /opt/alt/php53/usr/bin/php
- /opt/alt/php52/usr/bin/php
- /opt/alt/php44/usr/bin/php
Execute PHP file via a cronjob
In order for a PHP file to be executed via a cronjob, it must be called via a BASH script.
In the following, we would like to use the example of Nextcloud's cron.php to show how it can be called every 5 minutes.
- Create a bash script in the directory of the PHP file, e.g. nextcloud.sh
- Edit this file and add the following lines
#! /bin/bash
env -i /opt/alt/php83/usr/bin/php -f $PWD/httpdocs/nextcloud/cron.php
The first line tells the server that this is a BASH script. The second line executes the PHP file with the appropriate PHP version for the website (as listed under Available PHP CLI versions ). You may need to adjust the path to the file if your Nextcloud installation is not under httpdocs/nextcloud.
- Now create the scheduled task in Plesk as described above(Create cronjob in the customer menu (Plesk)).
TYPO3 Extension scheduler (Scheduler)
The scheduler extension supplied with TYPO3 enables the regular execution of tasks in TYPO3. These tasks include, for example
- Updating statistics
- Newsletter dispatch
- Reindexing for the search function
- Cleaning up the database
Previously, you could set up a separate cronjob for each of these tasks. In the scheduler, the tasks can be recorded in a schedule and only one cronjob is required to call up the scheduler and execute the tasks defined in it.
Set up cronjob
In the /httpdocs/typo3cms/projekt1/typo3conf directory, our hosting packages currently contain the scheduler.sh file with the following content:
#! /bin/bash
env -i /usr/local/bin/php7-72LATEST-CLI -f $PWD/typo3cms/projekt1/typo3/sysext/core/bin/typo3 scheduler:run
In this file you have to adjust the path information and the PHP version, depending on the PHP version set in the domain. The same PHP basic version should be set here. For example, change the line for PHP version 7.3 as follows
env -i /opt/alt/php73/usr/bin/php -f $PWD/httpdocs/typo3cms/...etc
If the TYPO3 project is located in a different directory, you must adjust the path name within the file accordingly.
Above you will find an overview of the available PHP-CLI versions and how you can have the script executed automatically via a cronjob.