Want to subscribe to topics you're interested in?
Become a Member

Wordpress WP-Cron Running Every Minute

Discussion in 'Blogs & CMS usage' started by mistermr, Mar 11, 2019.

  1. mistermr

    mistermr New Member

    9
    0
    1
    Dec 18, 2018
    Ratings:
    +0
    Local Time:
    6:20 AM
    I'm finding that the WP-Cron job is running every minute, which has caused some false flag reports with a firewall app (CleanTalk) I'm running in Wordpress. This is a small sample if the thousands of instances running a day:

    Code:
    107.155.x.x - - [10/Mar/2019:01:22:42 +0000] "POST /wp-cron.php?doing_wp_cron=1552180962.4250640869140625000000 HTTP/1.1" 200 31 "https://x.com/wp-cron.php?doing_wp_cron=1552180962.4250640869140625000000" "WordPress/5.1; https://x.com"
    107.155.x.x - - [10/Mar/2019:01:23:43 +0000] "POST /wp-cron.php?doing_wp_cron=1552181023.5979731082916259765625 HTTP/1.1" 200 31 "https://x.com/wp-cron.php?doing_wp_cron=1552181023.5979731082916259765625" "WordPress/5.1; https://x.com"
    107.155.x.x - - [10/Mar/2019:01:21:41 +0000] "POST /wp-cron.php?doing_wp_cron=1552180901.3255159854888916015625 HTTP/1.1" 200 31 "https://x.com/wp-cron.php?doing_wp_cron=1552180901.3255159854888916015625" "WordPress/5.1;
    107.155.x.x - - [10/Mar/2019:01:24:44 +0000] "POST /wp-cron.php?doing_wp_cron=1552181084.4996709823608398437500 HTTP/1.1" 200 31 "https://x.com/wp-cron.php?doing_wp_cron=1552181084.4996709823608398437500" "WordPress/5.1; https://x.com"
    I did an option 23 install, then restored via Updraft backups. The Cronjobs were untouched and here's the output:
    Code:
    13 23 * * * /usr/local/src/centminmod/tools/autoprotect.sh >/dev/null 2>&1
    0 */4 * * * /usr/bin/cminfo_updater 2>/dev/null
    #*/15 * * * * sleep 136s ; wget -O - -q -t 1 http://domain#2.com/wp-cron.php?doing_wp_cron > /dev/null 2>&1
    0 */8 * * * sleep 283s ;/root/tools/wp_updater_domain#2.com.sh >/dev/null 2>&1
    17 0 * * * "/root/.acme.sh"/acme.sh --cron --home "/root/.acme.sh" > /dev/null
    #*/15 * * * * sleep 149s ; wget -O - -q -t 1 http://domain#3.org/wp-cron.php?doing_wp_cron > /dev/null 2>&1
    0 */8 * * * sleep 255s ;/root/tools/wp_updater_domain#3.org.sh >/dev/null 2>&1
    
    Please fill in any relevant information that applies to you:
    • CentOS Version: CentOS 7 64bit
    • Centmin Mod Version Installed: 123.09beta01
    • When was last time updated Centmin Mod code base ? : Yesterday
    • Persistent Config:
      Code (Text):
      LETSENCRYPT_DETECT='y'
      


     
  2. mistermr

    mistermr New Member

    9
    0
    1
    Dec 18, 2018
    Ratings:
    +0
    Local Time:
    6:20 AM
    Here's another slug of it running:
    Code:
    107.155.x.x - - [10/Mar/2019:21:53:08 +0000] "POST /wp-cron.php?doing_wp_cron=1552254788.4354879856109619140625 HTTP/1.1" 200 31 "https://x.com/wp-cron.php?doing_wp_cron=1552254788.4354879856109619140625" "WordPress/5.1; https://x.com"
    107.155.x.x - - [10/Mar/2019:21:55:08 +0000] "POST /wp-cron.php?doing_wp_cron=1552254908.5936570167541503906250 HTTP/1.1" 200 31 "https://x.com/wp-cron.php?doing_wp_cron=1552254908.5936570167541503906250" "WordPress/5.1; https://x.com"
    107.155.x.x - - [10/Mar/2019:21:57:09 +0000] "POST /wp-cron.php?doing_wp_cron=1552255029.6603829860687255859375 HTTP/1.1" 200 31 "https://x.com/wp-cron.php?doing_wp_cron=1552255029.6603829860687255859375" "WordPress/5.1; https://x.com"
    107.155.x.x - - [10/Mar/2019:21:59:09 +0000] "POST /wp-cron.php?doing_wp_cron=1552255149.6297509670257568359375 HTTP/1.1" 200 31 "https://x.com/wp-cron.php?doing_wp_cron=1552255149.6297509670257568359375" "WordPress/5.1; https://x.com"
    107.155.x.x - - [10/Mar/2019:22:01:09 +0000] "POST /wp-cron.php?doing_wp_cron=1552255269.6855990886688232421875 HTTP/1.1" 200 31 "https://x.com/wp-cron.php?doing_wp_cron=1552255269.6855990886688232421875" "WordPress/5.1; https://x.com"
    
     
  3. eva2000

    eva2000 Administrator Staff Member

    39,815
    8,780
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +13,515
    Local Time:
    11:20 PM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    see cronjob list the wp crons have a hash # in front which means they are commented out/disabled and not running by default and they are set to run every 15 minutes if they were enabled anyway. So what you see is wordpress' native cronjob running i believe which run themselves so if you have busy wordpress site, they run more often ? How much traffic do your wordpress sites have ?

    I set cronjobs to disable/comment out as some folks reported issues using system cronjob in the past so disabled/commented out them in favour of wordpress native cronjobs.

    In your wordpress wp-config.php if you ran centmin.sh menu option 22 to create your wordpress site you would see a setting for
    Code (Text):
    define('DISABLE_WP_CRON', false);

    you can try changing that to true
    Code (Text):
    define('DISABLE_WP_CRON', true);

    then restart nginx and php-fpm
    Code (Text):
    nprestart

    and then in your system cronjob uncomment and enable those cronjobs by removing hash # in front of these 2
    Code (Text):
    #*/15 * * * * sleep 136s ; wget -O - -q -t 1 http://domain#2.com/wp-cron.php?doing_wp_cron > /dev/null 2>&1
    #*/15 * * * * sleep 149s ; wget -O - -q -t 1 http://domain#3.org/wp-cron.php?doing_wp_cron > /dev/null 2>&1
    

    to become
    Code (Text):
    */15 * * * * sleep 136s ; wget -O - -q -t 1 http://domain#2.com/wp-cron.php?doing_wp_cron > /dev/null 2>&1
    */15 * * * * sleep 149s ; wget -O - -q -t 1 http://domain#3.org/wp-cron.php?doing_wp_cron > /dev/null 2>&1
    

    use crontab -l to view current cronjobs and crontab -e command to invoke nano text editor see guide at HowTo: Add Jobs To cron Under Linux or UNIX?
     
  4. mistermr

    mistermr New Member

    9
    0
    1
    Dec 18, 2018
    Ratings:
    +0
    Local Time:
    6:20 AM
    When I set Disable to 'true', it seemed to resolve the issue. As I understand it, wp-cron runs every time someone visits the site, which makes no damn sense to me, but that's how they designed it.

    I set the crons to 30 minutes, but I wonder if you can clear something up for me...

    Each domain I install has a 'cronjobs' folder with the crons in it. Domain #2 will show the job for Domain 1 and 2, and the file for Domain #3 will show the jobs for Domains 1,2 and 3. Should Domain #3 'cronjoblist' only show the jobs FOR domain #3?
     
  5. eva2000

    eva2000 Administrator Staff Member

    39,815
    8,780
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +13,515
    Local Time:
    11:20 PM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    yeah it's a flawed design by wordpress hence option to switch to system cronjob that runs on schedule - just haven't had enough confidence to set to default as folks have reported sometimes their wordpress cronjobs fail to run with system setup instead of native wp-cron - it could be plugin conflicts etc but hard to diagnose. So left it to end users to decide.

    Those cronjob files are backup record purposes and not actual cronjobs, you would have 2 files at least
    • /home/nginx/domains/${vhostname}/cronjobs/cronjoblist-before-wp-cron.txt
    • /home/nginx/domains/${vhostname}/cronjobs/cronjoblist-after-wp-cron.txt
    They take a backup of what cronjobs are set before and after the current centmin.sh menu option 22 run. So yes you will have cronjobs listed for other stuff as it's a backup of all cronjobs from command
    Code (Text):
    crontab -l

    This is safeguard to ensure my routines don't mess up or wipe existing cronjobs that you may have setup yourself so you have a record/backup to restore them if you did have issues.
     
..