A “cron” can be created to perform a repetitive task at a particular time or interval; a “cronjob” is the word to generalize these tasks. Cronjobs are carried out by your web server (must be Unix-based)—therefore if in doubt, contact your hosting provider to clarify if they support cron functionalities.
Cronjobs facilitate in the everyday operation of your online shop. They can be used to automate a variety of tasks that occur at regular intervals, such as checking inventory for stock shortages or sending birthday greetings and/or newsletters to customers and partners.
Shopware offers two varieties of cronjobs. These can be used independently or together, each being programmed to perform at different times / intervals. In the current version, the difference between the two types of cronjobs can be easily recognized in the controller.
Shopware supports cron functionalities out-of-the-box, however the necessary plugins must be activated in advance. If you wish to make use of cron functionalities, simply install the required components by following the directions below.
To activate cron funtionalities, open the Plugin Manager and search for Plugins called "Cron", we'll list the plugins and it's containing cronjobs here:
The higher the number of additional cron tasks, the longer the processing time. This also means that if too many cronjobs are assigned simultaneously, some tasks might not be processed or take very long time.
The Cron plugin must be activated in order to run any Shopware cronjobs.
Open Configuration > Basic Settings > System > Cronjobs for an overview of cronjobs and configuration options.
Some of these cronjobs can only be carried out in combination with the CronRefresh plugin.
By using the cron security you can prevent the execution of your cronjobs by using a key, restricting the access of an IP or only execute when a user is logged in into the backend. You can find the configuration in the Cron plugin:
It is not possible to combine filters, as the prompt does not test for all fields. The request will pass if one of the fields contains information!
Cronjobs are run on your server, therefore if in doubt, please contact your hosting provider in order to determine whether or not cronjobs are possible within their realm of services.
To execute cronjobs per browser, call the following URL in your browser:
// Executes all cronjobs EXCEPT newsletter http://www.myshop.com/backend/cron // Executes only the newsletter cronjob http://www.myshop.com/backend/Newsletter/cron
The result can be read in your browser as text. Please note that some cronjobs might extend beyond the defined connection time or script runtime. In such cases, you can reduce the number of cronjobs, increase the execution time allowed by your hosting provider or run the cronjobs by shell / console. Alternatively you can set your cronjobs to different start times, so that every call only execute a few cronjobs to avoid timeouts.
Shell does not place any limitations on the script runtime. This also means even without a connection to a browser, cronjobs can be launched by shell or console command. You will find these settings within the management interface of your hosting provider (you can also contact them for more information on setting up cronjobs via shell).
To execute cronjobs via shell, you can use the following examples (but make sure to navigate to the Shopware directory first!):
Classic method: This method is deprecated and not recommended by us. Please use for your cronjobs our CLI-Tools.
// Execution directly in the Shopware directory: php5 shopware.php /backend/cron // (intelligent) newsletter cd /path/toShop && php5 shopware.php /backend/Newsletter/cron
Recommended method via sw tools:
// Execute all pending cronjobs php bin/console sw:cron:run // Execute a cronjob by action name: php bin/console sw:cron:run ACTION-NAME // Forced execution of the Cronjobs: php bin/console sw:cron:run ACTION-NAME -f
The action name can change after the first execution, but your first given action name is still valid. (e.g. Shopwarte_CronJob_Clearing > Here "Clearing" is the needed action name). Executing cronjobs by action name ignores the "active" setting in the backend, the cronjob will be executed, even if its inactive!
If you execute cronjobs via shell, please make sure that the executing user is the same which executes Shopware, otherwise it may cause permission issues.
Setting up the Cronjob call is made by the hosting, so make sure to configure it in your hosting. If you need help doing that, please contact your hoster.
We recommend that you run the cronjob every 10 – 15 minutes. To find out which PHP interpreter you are using, you can use the whichphp5 command.
Some hosts are not able to call cronjobs. Should this be the case with your hosting provider, you must create a file (i.e. cron.php) in the root directory and use one of the following examples.
The interpreter call (#!/../../php5) is also required by your provider.
#!/usr/bin/php <?php echo file_get_contents('http://www.myshop.com/backend/cron');
*/15 * * * * wget -q http://www.myshop.com/backend/cron
Save the file in ASCII format & set the file permission to 755.
* * * * * Command to be executed - - - - - | | | | | | | | | +-- Weekday (0 - 7) (Sunday is 0 and 7) | | | +------ Month (1 - 12) | | +---------- Day (1 - 31) | +------------- Hour (0 - 23) +----------------- Minute (0 - 59)
Some functions of shopware can not be automatically done with the cron plugin. For this case it's usefull to use our CLI Tools - you can set up the cron as described in Call per shell / console .
This command allows you to build up the http cache - its necessary after you have cleared the http cache to improve the performance of your shop. This command is not available in the shopware cron plugin, but you can easily set it up in your server administration.
php bin/console sw:warm:cache:http
You find more usefull commands in the Shopware CLI Article.
You can send the cronjob through data cleansing using one click in the backend under Configuration > Basic settings > Cronjobs. You will then receive an email with a protocol. If the email does not arrive, please check that the email path is undisturbed (i.e. not in a spam folder) or if the mail function of your hosting provider has been established.
With UNIX / Linus servers, check that both the cronjob and the files for the cronjob contain the normal privileges to run in the basic settings. The rights must be set, at minimum, to 755.
Normally all Linux based servers support the mail() function without requiring additional configuration. Windows servers do not support this function, therefore additional steps are required.
Set up in the backend under Configuration > Basic settings > Shop settings > Mailer and enter a Mail host. As a method, enter “smtp” as the Mail host—the Shopware server will now communicate with the SMTP host. Enter the SMTP username and password in the following fields. Check with your email provider to see whether a plain, login or encrypted CRAM-MD5 method is necessary for the transmission of the access data.