Setting up a Cron Job to call wp-cron

Posted December 8, 2020 1.2k views
System ToolsUbuntu 18.04

I have a wordpress website running a LearnDash with the Notifications Add-on. LearnDash recommends a Cron Job to manage this process because the native Wordpress mail setup isn’t sufficient. Here’s an article from LearnDash explaining this.

I followed this article to set up a cron job but it doesn’t seem to be working.

Any ideas why?

Here is my crontab after following the steps and running crontab -l:

# Edit this file to introduce tasks to be run by cron.
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').# 
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
# For more information see the manual pages of crontab(5) and cron(8)
# m h  dom mon dow   command

* * * * * wget -q -O - ''
edited by MattIPv4

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

Hi there @justinw,

This actually looks all good. If for any reason this is still not working, I could suggest a couple of things:

  • SSH to your Droplet and run the command manually without the -q flag:
wget -O - ''

This should show you any errors that could be preventing the cron from wokring

  • Check the syslog log to see if there are any errors in there which could give you more information about the problem:
sudo tail -100 /var/log/syslog

Let me know how it goes!

  • Thanks Bobby! This is the most traction I feel like I’ve been able to get on it!

    When I ran the command manually without the -q flag, I get a status 200 message.

    When I run, sudo tail -100 /var/log/syslog I don’t get any errors that I can see.

    LearnDash now recognizes the Cron Job is set up. However, the timestamp for “last run” doesn’t appear to be updating which makes me think it is not running automatically.

    Is it possible that when I ran it manually, it worked but it isn’t running automatically? If so, why?

    • Hi there @justinw,

      Yes indeed, it sounds like that the cron job is not running.

      What I could suggest is checking your cron log to see if there is any information in there.

      Feel free to share the logs here as well.


      • Here is the last several entries in the log @bobbyiliev.

        Jan  5 16:52:01 wordpress-gd-2vcpu-8gb-sfo2-01 CRON[17996]: (root) CMD (wget -q -O - "")
        Jan  5 16:53:01 wordpress-gd-2vcpu-8gb-sfo2-01 CRON[18009]: (root) CMD (wget -q -O - "")
        Jan  5 16:54:01 wordpress-gd-2vcpu-8gb-sfo2-01 CRON[18020]: (root) CMD (wget -q -O - "")
        Jan  5 16:55:01 wordpress-gd-2vcpu-8gb-sfo2-01 CRON[18036]: (root) CMD (wget -q -O - "")
        Jan  5 16:56:01 wordpress-gd-2vcpu-8gb-sfo2-01 CRON[18045]: (root) CMD (wget -q -O - "")
        Jan  5 16:57:01 wordpress-gd-2vcpu-8gb-sfo2-01 CRON[18057]: (root) CMD (wget -q -O - "")
        Jan  5 16:58:01 wordpress-gd-2vcpu-8gb-sfo2-01 CRON[18067]: (root) CMD (wget -q -O - "")
        Jan  5 16:59:01 wordpress-gd-2vcpu-8gb-sfo2-01 CRON[18074]: (root) CMD (wget -q -O - "")
        Jan  5 17:00:01 wordpress-gd-2vcpu-8gb-sfo2-01 CRON[18097]: (root) CMD (wget -q -O - "")
        Jan  5 17:01:01 wordpress-gd-2vcpu-8gb-sfo2-01 CRON[18113]: (root) CMD (wget -q -O - "")
        Jan  5 17:02:01 wordpress-gd-2vcpu-8gb-sfo2-01 CRON[18134]: (root) CMD (wget -q -O - "")
        Jan  5 17:03:01 wordpress-gd-2vcpu-8gb-sfo2-01 CRON[18145]: (root) CMD (wget -q -O - "")
        Jan  5 17:04:01 wordpress-gd-2vcpu-8gb-sfo2-01 CRON[18164]: (root) CMD (wget -q -O - "")
        Jan  5 17:05:01 wordpress-gd-2vcpu-8gb-sfo2-01 CRON[18202]: (root) CMD (wget -q -O - "")
        Jan  5 17:06:01 wordpress-gd-2vcpu-8gb-sfo2-01 CRON[18222]: (root) CMD (wget -q -O - "")```
        If I'm understanding this correctly, it seems like it's firing each minute but not actually executing anything. 
        • Hi there,

          Yes, indeed it looks all good!

          Have you tried running that command from the same server that you’ve got the cron job set up on?

          The only thing that is coming to my mind at the moment is that the hosts file on the server itself could be causing that behavior.


          • Hey @bobbyiliev,

            Unless I did something wrong, yes.

            I ran that command on the same droplet that the cron job is set up which is the same droplet where the website is hosted.

            Is that correct?

            What should I look at within the hosts file?