Setting Up A Cron Job In Magento
Programming on January 16, 2018
A cron job is an automated task that is actioned by the server, most people think that a cron runs automatically. This article has been written to show that this is not the case.
When a developer has finished designing and developing a Magento website the cron must be activated. If not actioned the following Magento functions will be unsuccessful.
- Site map generation
- Other extensions (cron extensions)
To action the cron, the developer will program the server to execute cron.php file every 10 to 20 minutes. This can obviously be changed to how long it takes to run a certain cron (thus minimising cron overlapping).
The following will summarise how to set-up cron in a Plesk CP.
1.0. Navigate to the sites domain, click Cron Tab
1.2. Click on the desired user
1.3. Click Schedule a Task for <user>
This will open a new page which can look quite complicated for some users. Essentially this is where the command, time, and dates for the cron are set.
Normally a Magento cron only needs to run every 10 minutes. To set this configuration add the following to the required fields:
- Switched on = Checked
- Minute = */10 (star=every)
- Hour = *
- Day of month = *
- Month = *
- Day of week = *
- Command = /usr/bin/php -f /var/www/vhosts/mydomain.com/httpdocs/cron.php
Above, the cron is set to run every 10 minutes, every hour, every day, every month, and to run the following command:
/usr/bin/php -f /