Cron schedules are used to trigger jobs or tasks to run at periodic times, dates or intervals. For example, you might set up a cron schedule to run a task once a month, once a day, once an hour, or the first Sunday of every month.
The Brightpearl Magento extension allows some interactions between Brightpearl and Magento to be set up on a cron schedule in addition to the real-time updates. This means that full sweeps of the system can be performed during quiet times, which will ensure all updates are successfully made and the two systems are synchronized.
These interactions are:
- Import stock levels (bulk)
- Export order
- Export order status
- Export order payment
- Import prices
- Export SKUs
- Log cleaning
The frequency of cronjobs should be set with both the Magento server specifications and business needs in mind.
Running cronjobs too frequently could cause strain and slow down the Magento server, but they should be run frequently enough that system data can be relied upon.
Writing cron expressions
When setting up a cron schedule on the Brightpearl Magento extension it must be entered as a cron expression. This consists of five segments which describe individual details of the schedule. Each segment represents the following information:
|Segment||Name||Allowed values||Allowed characters|
|1||Minutes||0-59||, - * /|
|2||Hours||0-23||, - * /|
|3||Day of month||1-31||, - * ? / L W C|
|4||Months||1-12 or JAN-DEC||, - * /|
|5||Day of week||1-7 or SUN-SAT||, - * ? / L C #|
|6 (optional)||Year||empty, 1970-2099||, - * /|
A simple cron expression meaning "run at midnight everyday" can be written like this:
0 0 * * *
Import stock levels (bulk) cronjob
This interaction updates all product quantities in Magento and should be set to run at least once a day during out of hours.
If there is a specific time when inventory is generally updated in Brightpearl, for example, a time deliveries usually arrive, or a regular stock import that is done, it may be appropriate to set the cronjob to run more frequently.
Some suggestions are:
|Run at midnight every day
|0 0 * * *|
|Run every 12 hours||0 */12 * * *|
|Run at 2PM every day||0 14 * * *|
Note: Ensure that the cronjob doesn't overlap by running again before the last has completed.
Export orders cronjob
This interaction sends new Magento orders to Brightpearl and should be set to run fairly frequently.
Generally new orders will be queued one by one and exported to Brightpearl as soon as the triggers are hit. This cronjob is useful for ensuring no orders are missed.
|Once an hour, every hour
|0 */1 * * *|
At peak times when there are likely be a higher volume of sales coming through Magento, such as during a flash sale, on Black Friday or Cyber Monday, this cronjob can be set to run more frequently to reduce any delay.
|Once every 30 minutes
|0 */30 * * *|
Export order status cronjob
This interaction updates the status of orders in Brightpearl. These changes are generally picked up as and when they are made but setting a back up cronjob ensures none are missed. Running this interaction shortly after the order export cronjob is recommended.
Run at 25 minutes past every hour: 25 */1 * * *
Export order payments cronjob
This interaction sends payment details to Brightpearl.
Payment details are generally sent as and when a payment occurs, but using a cronjob ensures any delayed payments are caught. Running this interaction shortly after the order export cron is recommended.
|10 minutes past every hour||10 */1 * * *|
Import prices cronjob
This interaction updates all prices in Magento. When this is run depends on when prices are generally being updated in Brightpearl.
Here some suggestions:
|Run the first of each month at midnight||0 0 1 * *|
|Run every other day at midnight||0 0 */2 * *|
|Run every Monday at 7AM||0 7 * * MON|
Log cleaning cronjob
The log is where details of the interactions occurring between Brightpearl and Magento can be seen.
This includes successful interactions as well as any errors that may need action.
The log cleaning interaction will clean the log. Running this interaction is important for ensuring that Magento disk space is freed up.
Set this interaction to run once each night.
|4AM every day||0 4 * * *|