11

About Magento 1.9

I want to run Magento's cron.php every minute because, I want sales email to be sent the soonest possible on client order. So besides the email function can someone let me know what the default cron.php does in the sense how wise it is to run it every minute, and if we do run it every minute what to be aware of before 1 minute becomes a problem for these jobs.

1 Answer 1

8

Completely safe - and in most cases mandatory, otherwise jobs can end up being skipped.

Just make sure you are executing cron.sh not cron.php

Just note that the regularity of the cron itself won't dictate when cron operations take place - the module itself does that.

Eg. Using the awesome MageRun to list tasks,

[www-data@acc1 .microcloud ~]
[~]$ mr_examplecom sys:cron:list


  Cronjob List


+-----------------------------------------+------+----+----+----+----+
| Job                                     | m    | h  | D  | M  | WD |
+-----------------------------------------+------+----+----+----+----+
| aggregate_sales_report_bestsellers_data | 0    | 0  | *  | *  | *  |
| aggregate_sales_report_coupons_data     | 0    | 0  | *  | *  | *  |
| aggregate_sales_report_invoiced_data    | 0    | 0  | *  | *  | *  |
| aggregate_sales_report_order_data       | 0    | 0  | *  | *  | *  |
| aggregate_sales_report_refunded_data    | 0    | 0  | *  | *  | *  |
| aggregate_sales_report_shipment_data    | 0    | 0  | *  | *  | *  |
| aggregate_sales_report_tax_data         | 0    | 0  | *  | *  | *  |
| captcha_delete_expired_images           | */10 | *  | *  | *  | *  |
| captcha_delete_old_attempts             | */30 | *  | *  | *  | *  |
| catalog_product_alert                   |      |    |    |    |    |
| catalog_product_index_price_reindex_all | 0    | 2  | *  | *  | *  |
| catalogrule_apply_all                   | 0    | 1  | *  | *  | *  |
| core_clean_cache                        | 30   | 2  | *  | *  | *  |
| currency_rates_update                   |      |    |    |    |    |
| log_clean                               |      |    |    |    |    |
| newsletter_send_all                     | */5  | *  | *  | *  | *  |
| paypal_fetch_settlement_reports         |      |    |    |    |    |
| persistent_clear_expired                | 0    | 0  | *  | *  | *  |
| sales_clean_quotes                      | 0    | 0  | *  | *  | *  |
| sitemap_generate                        |      |    |    |    |    |
| system_backup                           |      |    |    |    |    |
| xmlconnect_notification_send_all        | */5  | *  | *  | *  | *  |
+-----------------------------------------+------+----+----+----+----+

You can see that amongst the tasks, the most regular in this list is every 5 minutes. Which means that even if the cron were to be configured to run every minute, it wouldn't make a difference, as newsletter_send_all and xmlconnect_notification_send_all would only run every 5 minutes.


If CLI isn't your bag, then you can use (the equally awesome) Aoe Scheduler to visualise the timeline.

This will let you see when tasks are due to run, and if they are being executed or skipped.

4
  • Why cron.sh over cron.php?
    – Navarr
    Aug 20, 2015 at 23:25
  • cron.sh makes sure that only one instance of the script runs at the time Aug 21, 2015 at 5:31
  • 1
    Perhaps also worth noting that if you don't have Magento cron running as regularly as the most frequently running job, depending on your cron timings you can also get 2 instances of the same job running at the same time and this can cause problems. So I would agree with Ben, having it run every minute is the best idea then you know this situation can never occur. Aug 21, 2015 at 8:00
  • @Jonathan Hussey: As far as I know all jobs are executed sequentially. So when you run the scheduler with cron.sh you should be fine. Isn't it?
    – hellcode
    Dec 11, 2015 at 15:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.