Cron Jobs - How do I check if they are working or not?

Hi all,
I have a great hosting company that has setup the cron jobs for my M2.3 site. But I do not get any e-mails telling me that the cron jobs are working fine. Is this something I am supposed to get? What is the easiest way to double check that the cron jobs are working 100% as the are supposed to? (the hosting company only provides installation and setup - no further support/advice).

Further, it might be a rare question, how to use the benefits of using cron jobs for example for speed up the site or newsletters? I have only read that the cron jobs are used to validate the status of your site, to detect errors etc etc but in this forum I read about other benefits too. Please share :slight_smile:

There are several ways to check what cron jobs are running. If you have cpanel installed as part of your hosting services, logon to cpanel and look for an icon titled “Cron Jobs”, this is usually located under the “Advanced” section. Scroll to the “Current Cron Jobs”, if any are setup they should be listed in this section.

Likewise, if you have SSH access into your server hosting Magento, logon to your server via SSH, switch to your Magento home directory (typically this is “public_html”) and list the current cron jobs by running this from the command line “crontab -l”. If you do not have SSH configured but you do have cpanel, you should also have a “Terminal” icon available in the “Advanced” section. This opens a terminal session from where you can run commands.

The following switch “2>&1” will suppress any cron jobs from piping to email. However, depending on how your cron jobs are setup, you may not want to have them email you every time they run, or you will fill up your mailbox with worthless messages. The best alternative is to have your cron jobs pipe to a LOG file which you can check regularly.

As for the last part of your inquiry, it is a bit ambiguous. That said however, you can schedule a multitude of cron jobs, for example to clear your Magento cache regularly or, reindex your Magento Indexes. However, all this requires command line syntax knowledge as well as more advanced Magento knowledge.
Hope this helps.

Kenster

Checking Magento Cron
My tip for checking that the Magento cron tasks are running correctly is by checking the system.log file. This is located in the Magento root directory under:

<magento_root>/var/system.log

The location of <magento_root> will depend on where your hosting company put it. Assuming that your hosting company has installed cPanel (which is common), you can access this file from their built-in FTP application. When you open the file, you’ll find that approximately every 60 seconds there will be a load of text written to the file that would look something like this:

[2019-03-11 06:53:04] main.INFO: Cron Job mst_report_email is run [] []
[2019-03-11 06:53:04] main.INFO: Cron Job mst_report_email is successfully finished. Statistics: {"sum":0.0020160675048828,"count":1,"realmem":0,"emalloc":43568,"realmem_start":148897792,"emalloc_start":145677176} [] []
[2019-03-11 06:53:04] main.INFO: Cron Job xtento_xtcore_register_last_cron_execution is run [] []
[2019-03-11 06:53:04] main.INFO: Cron Job xtento_xtcore_register_last_cron_execution is successfully finished. Statistics: {"sum":0.0047497749328613,"count":1,"realmem":0,"emalloc":1176,"realmem_start":148897792,"emalloc_start":145723048} [] []
[2019-03-11 06:53:04] main.INFO: Cron Job indexer_reindex_all_invalid is run [] []
[2019-03-11 06:53:04] main.INFO: Cron Job indexer_reindex_all_invalid is successfully finished. Statistics: {"sum":0.032444953918457,"count":1,"realmem":0,"emalloc":593760,"realmem_start":148897792,"emalloc_start":134149296} [] []
[2019-03-11 06:53:04] main.INFO: Cron Job indexer_update_all_views is run [] []
[2019-03-11 06:53:04] main.INFO: Cron Job indexer_update_all_views is successfully finished. Statistics: {"sum":0.25076198577881,"count":1,"realmem":0,"emalloc":3293504,"realmem_start":148897792,"emalloc_start":134745096} [] []

If you see this, then the Magento cron tasks are working correctly.

You can also tell that your Magento cron tasks are running because the Web Setup Wizard will check it during the Readiness Check. In another post you’ve screen-shot this and I can see that it’s passed the check.

Other Benefits

I’m not sure that cron tasks work the same way that you think. To try and answer your question, cron is used to schedule tasks to run at specific times. They simply run a command of your choosing. The commands that you wish to run depend on you. Magento uses 3 cron scripts to run a multitude of tasks required to make the store work. There aren’t any other cron tasks that Magento would benefit from to make the site “faster”.

Having said that, you can request your Hosting Company to setup something called “log rotation” (if they haven’t already). This utilises a different set of cron tasks ran by the Operating System than archives your log files every week so that they don’t grow out of hand and eat into your disk space. It won’t speed your site up but would help with clutter.