Cron schedules are used to trigger jobs or tasks to run at periodic times, dates or intervals, for example, 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||emplty, 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.
Run at midnight everyday: 0 0 * * * (recommended)
Run every 12 hours: 0 */12 * * *
Run at 2pm everyday: 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 * * * (recommended)
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.
Run once every 30 minutes: */30 * * * * (peak times)
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. These 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.
Run 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
Export SKUs cronjob
This interaction is used to update the channel availability display within Brightpearl - as seen on the product list. It allows you to see which products are listed on Magento and the quantity available (as of last export). If the stock import is set to run overnight, set this cronjob to run a few hours after it.
Run at 2am every day: 0 2 * * *
Log cleaning cronjob
The log is where details of the interactions occuring between Brightpearl and Magento can be seen. This includes successful interactions as well as any errors that may need action. This interaction will clean the log. Running this interaction is important for ensuring that Magento disk space if free'd up. Set this interaction to run once each night, a few hours after the SKU export.
Run at 4am every day: 0 4 * * *