Wordpress scheduled operations

Discussion in 'General' started by Skyflash, Oct 27, 2011.

  1. Skyflash

    Skyflash New Member

    (sorry for my bad english... i'll try explain the problem at my best...)

    I have a trouble with any WP installation i do in ISPConfig. I've tried on thw different ISPConfig, one Ubuntu 11.10 based and other CentOS 5.5 based, following the Perfect Server documents.

    I'm not a coder, but i think i understood WP don't use any cron job for schedule post publishing and other scheduled functions like a scheduled db backup via many plugins. Wordpress use a special function, called wp_schedule_event like this:
    I've done many tests, but the result was the same: every envinronment i tested, every website wp-based, no scheduled actions is working.

    I've used as user many other panels in the past, and i can say that in cPanel and Plesk the problem doesn't exists.

    Someone can help me, pls?
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    I use a lot of wordpress installs on my servers and I can say you that I never had this problem on any ispconfig server. So this problem is not related to the use of ispconfig.

    Which PHP mode have you used for the website? CMS systems like wordpress require php-fcgi and suexec must be switched on in the site settings. Beside that, make sure that the files and folders in the web directory are owned by the web user and client group of this website.
     
  3. Skyflash

    Skyflash New Member

    Bad news for me, because i'm having the trouble on both installs :(

    I'm using Suexec and SuPhp

    I think the files ownership is ok:

    Code:
    root@server01:/var/www/clients/client1/web1/web# ll
    total 280
    drwx--x--- 7 web1 client1  4096 2011-10-25 12:30 ./
    drwxr-x--x 6 web1 client1  4096 2011-10-27 00:30 ../
    drwxr-xr-x 2 web1 client1  4096 2011-10-25 12:15 error/
    -rw-r--r-- 1 web1 client1   397 2011-10-25 12:25 index.php
    -rw-r--r-- 1 web1 client1   402 2011-10-25 12:25 LEGGIMI.txt
    -rw-r--r-- 1 web1 client1 16572 2011-10-25 12:25 license.txt
    -rw-r--r-- 1 web1 client1 24732 2011-10-25 12:25 licenza.html
    -rw-r--r-- 1 web1 client1  8858 2011-10-25 12:25 readme.html
    drwxr-xr-x 2 root root     4096 2011-10-26 00:30 stats/
    -rw-r--r-- 1 web1 client1  4343 2011-10-25 12:25 wp-activate.php
    drwxr-xr-x 9 web1 client1  4096 2011-10-25 12:25 wp-admin/
    -rw-r--r-- 1 web1 client1 40243 2011-10-25 12:25 wp-app.php
    -rw-r--r-- 1 web1 client1   226 2011-10-25 12:25 wp-atom.php
    -rw-r--r-- 1 web1 client1   274 2011-10-25 12:25 wp-blog-header.php
    -rw-r--r-- 1 web1 client1  3931 2011-10-25 12:25 wp-comments-post.php
    -rw-r--r-- 1 web1 client1   244 2011-10-25 12:25 wp-commentsrss2.php
    -rw-r--r-- 1 web1 client1  3926 2011-10-25 12:27 wp-config.php
    -rw-r--r-- 1 web1 client1  3639 2011-10-25 12:25 wp-config-sample.php
    drwxr-xr-x 8 web1 client1  4096 2011-10-25 13:36 wp-content/
    -rw-r--r-- 1 web1 client1  1255 2011-10-25 12:25 wp-cron.php
    -rw-r--r-- 1 web1 client1   246 2011-10-25 12:25 wp-feed.php
    drwxr-xr-x 8 web1 client1  4096 2011-10-25 12:26 wp-includes/
    -rw-r--r-- 1 web1 client1  1997 2011-10-25 12:25 wp-links-opml.php
    -rw-r--r-- 1 web1 client1  2570 2011-10-25 12:25 wp-load.php
    -rw-r--r-- 1 web1 client1 27601 2011-10-25 12:25 wp-login.php
    -rw-r--r-- 1 web1 client1  7774 2011-10-25 12:25 wp-mail.php
    -rw-r--r-- 1 web1 client1   494 2011-10-25 12:25 wp-pass.php
    -rw-r--r-- 1 web1 client1   224 2011-10-25 12:25 wp-rdf.php
    -rw-r--r-- 1 web1 client1   334 2011-10-25 12:25 wp-register.php
    -rw-r--r-- 1 web1 client1   226 2011-10-25 12:25 wp-rss2.php
    -rw-r--r-- 1 web1 client1   224 2011-10-25 12:25 wp-rss.php
    -rw-r--r-- 1 web1 client1  9839 2011-10-25 12:25 wp-settings.php
    -rw-r--r-- 1 web1 client1 18646 2011-10-25 12:25 wp-signup.php
    -rw-r--r-- 1 web1 client1  3702 2011-10-25 12:25 wp-trackback.php
    -rw-r--r-- 1 web1 client1  3266 2011-10-25 12:25 xmlrpc.php
    
     
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    The ownerships are ok. Please switch from suphp to fastcgi.
     
  5. Skyflash

    Skyflash New Member

    Same result :(

    [​IMG]

    [​IMG]
     
    Last edited: Oct 27, 2011
  6. till

    till Super Moderator Staff Member ISPConfig Developer

    1) Have you waited long enough? A switch in the config takes at least 1 minute.
    2) Are there enough pageviews on the website in the meantime, as the cron gets only executed in wordpress if there is a pageview.
    3) Do you use any caching plugins in wordpress? As plugins like w3totalcache and other plugins that use a .htaccess redirect to temporary created html files can prevent that the wordpress cron work.
     
  7. Skyflash

    Skyflash New Member

    Yes. About 10 minutes after the switch. Tried a second time some minutes ago

    In the test installation, i refresh myself the page. In my personal blog i have about 5-600 visits per day

    No, no caching plugin. The test installation is a clean WP 3.2.1

    Is there something similar to a fgci or suphp log?
     
  8. till

    till Super Moderator Staff Member ISPConfig Developer

    Everything is logged to the apache access and error log, you find them in the log directory of the website.
     
  9. Skyflash

    Skyflash New Member

    The error.log seems ok:
    Code:
    [Thu Oct 27 10:14:30 2011] [error] [client 93.63.146.178] File does not exist: /var/www/skyflashtest.biz/web/favicon.ico
    [Thu Oct 27 10:14:30 2011] [error] [client 93.63.146.178] File does not exist: /var/www/skyflashtest.biz/web/favicon.ico
    [Thu Oct 27 10:14:38 2011] [error] [client 93.63.146.178] File does not exist: /var/www/skyflashtest.biz/web/favicon.ico
    [Thu Oct 27 10:14:40 2011] [error] [client 93.63.146.178] File does not exist: /var/www/skyflashtest.biz/web/favicon.ico
    [Thu Oct 27 10:15:50 2011] [error] [client 93.63.146.178] File does not exist: /var/www/skyflashtest.biz/web/favicon.ico
    [Thu Oct 27 10:16:39 2011] [error] [client 93.63.146.178] File does not exist: /var/www/skyflashtest.biz/web/favicon.ico
    [Thu Oct 27 10:16:41 2011] [error] [client 93.63.146.178] File does not exist: /var/www/skyflashtest.biz/web/favicon.ico
    [Thu Oct 27 10:19:12 2011] [error] [client 93.63.146.178] File does not exist: /var/www/skyflashtest.biz/web/favicon.ico
    [Thu Oct 27 10:19:15 2011] [error] [client 93.63.146.178] File does not exist: /var/www/skyflashtest.biz/web/favicon.ico
    
    access.log
    Here i edited and scheduled the post:
    Code:
    93.63.146.178 - - [27/Oct/2011:10:30:31 +0200] "POST /wp-admin/post.php HTTP/1.1" 302 20 "http://skyflashtest.biz/wp-admin/post.php?post=5&action=edit" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.202 Safari/535.1"
    [B]93.63.146.178 - - [27/Oct/2011:10:30:31 +0200] "GET /wp-admin/post.php?post=5&action=edit&message=1 HTTP/1.1" 200 19881 "http://skyflashtest.biz/wp-admin/post.php?post=5&action=edit" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.202 Safari/535.1"
    93.63.146.178 - - [27/Oct/2011:10:30:32 +0200] "GET /wp-admin/admin-ajax.php?action=oembed-cache&post=5 HTTP/1.1" 200 21 "http://skyflashtest.biz/wp-admin/post.php?post=5&action=edit&message=1" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.202 Safari/535.1"[/B]
    93.63.146.178 - - [27/Oct/2011:10:30:33 +0200] "GET /favicon.ico HTTP/1.1" 404 809 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.202 Safari/535.1"
    93.63.146.178 - - [27/Oct/2011:10:30:36 +0200] "GET / HTTP/1.1" 200 2984 "http://skyflashtest.biz/wp-admin/post.php?post=5&action=edit&message=1" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.202 Safari/535.1"
    93.63.146.178 - - [27/Oct/2011:10:30:37 +0200] "GET /favicon.ico HTTP/1.1" 404 809 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.202 Safari/535.1"
    
    and now is the time for publishing. I refresh the page:
    Code:
    93.63.146.178 - - [27/Oct/2011:10:30:32 +0200] "GET /wp-admin/admin-ajax.php?action=oembed-cache&post=5 HTTP/1.1" 200 21 "http://skyflashtest.biz/wp-admin/post.php?post=5&action=edit&message=1" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.202 Safari/535.1"
    93.63.146.178 - - [27/Oct/2011:10:30:33 +0200] "GET /favicon.ico HTTP/1.1" 404 809 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.202 Safari/535.1"
    93.63.146.178 - - [27/Oct/2011:10:30:36 +0200] "GET / HTTP/1.1" 200 2984 "http://skyflashtest.biz/wp-admin/post.php?post=5&action=edit&message=1" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.202 Safari/535.1"
    93.63.146.178 - - [27/Oct/2011:10:30:37 +0200] "GET /favicon.ico HTTP/1.1" 404 809 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.202 Safari/535.1"
    93.63.146.178 - - [27/Oct/2011:10:32:06 +0200] "GET / HTTP/1.1" 200 2983 "http://skyflashtest.biz/" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.202 Safari/535.1"
    93.63.146.178 - - [27/Oct/2011:10:32:06 +0200] "GET /favicon.ico HTTP/1.1" 404 809 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.202 Safari/535.1"
    93.63.146.178 - - [27/Oct/2011:10:32:09 +0200] "GET / HTTP/1.1" 200 2982 "http://skyflashtest.biz/" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.202 Safari/535.1"
    93.63.146.178 - - [27/Oct/2011:10:32:10 +0200] "GET /favicon.ico HTTP/1.1" 404 809 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.202 Safari/535.1"
    
    I can't see anything wrong :(
     
    Last edited: Oct 27, 2011
  10. till

    till Super Moderator Staff Member ISPConfig Developer

    Please check that this value is not set in wp-config.php or that its set to false:

    define('DISABLE_WP_CRON', true);

    If its set to true, the internal cron in wordpress is disabled.

    another problem can be the max php memory size or max execution time. You can try to increase them in the cgi php.ini file and then restart apache.
     
  11. till

    till Super Moderator Staff Member ISPConfig Developer

    Another possible problem is described here:

    http://www.bloghighlight.com/wordpress-post-missed-schedule/

    The cron in wordpress can fail if the system time is incorrect. Please check if your system time is ok e.g. with the date comand on the shell and also check in the php.ini file if the correct date.timezone is set there.
     
  12. Skyflash

    Skyflash New Member

    Ok, checked. The value was not present, so wp understand it is set to false by default. I've added it, and set to false
    Code:
    define('DISABLE_WP_CRON', false);
    Code:
    vi /etc/php5/apache2/php.ini
    
    ; Maximum execution time of each script, in seconds
    ; http://php.net/max-execution-time
    ; Note: This directive is hardcoded to 0 for the CLI SAPI
    max_execution_time = 30
    
    
    ; Maximum amount of memory a script may consume (128MB)
    ; http://php.net/memory-limit
    memory_limit = 128M
    Code:
    vi /etc/php5/cgi/php.ini
    
    ; Maximum execution time of each script, in seconds
    ; http://php.net/max-execution-time
    ; Note: This directive is hardcoded to 0 for the CLI SAPI
    max_execution_time = 30
    
    ; Maximum amount of memory a script may consume (128MB)
    ; http://php.net/memory-limit
    memory_limit = 128M
    :(
     
  13. till

    till Super Moderator Staff Member ISPConfig Developer

    Please set max execution time to 300 and Memory Limit to 256M and restart apache. The Memory Limit required for Wordpress is 256M for Wordpress versions > 2.7
     
  14. Skyflash

    Skyflash New Member

    Don't works :(
    It only works if i manually call the cron script http://skyflashtest.biz/wp-cron.php

    I set limits suggested by you
    I set date.timezone, previously commented in cgi and php php.ini

    Code:
    [Date]
    ; Defines the default timezone used by the date functions
    ; http://php.net/date.timezone
    date.timezone = Europe/Rome
    I don't know what i can do :(
     
  15. till

    till Super Moderator Staff Member ISPConfig Developer

  16. Skyflash

    Skyflash New Member

    I've found this:

    Code:
    [B]/wp-content/debug.log
    [/B][27-Oct-2011 09:40:05] PHP Warning:  fopen(http://skyflashtest.biz/wp-cron.php?doing_wp_cron): failed to open stream: Connection timed out in /var/www/clients/client1/web1/web/wp-includes/class-http.php on line 876
    The timestamp in the log seems the UTC time, because my zone real time is +2 (9.40 UTC = 11.40 Europe/Rome)

    The correct timezone is configured in WP
     
  17. till

    till Super Moderator Staff Member ISPConfig Developer

    You should check if the correct time zone is configured in linux, this setting is normally done during initial installation of the base linux.
     
  18. Skyflash

    Skyflash New Member

    root@server01:/var/www/clients/client1/web1/log# dpkg-reconfigure tzdata

    Current default time zone: 'Europe/Rome'
    Local time is now: Thu Oct 27 11:49:08 CEST 2011.
    Universal Time is now: Thu Oct 27 09:49:08 UTC 2011.

    But i think the real problem is not the timezone, but the PHP Warning: fopen(http://skyflashtest.biz/wp-cron.php?doing_wp_cron): failed to open stream: Connection timed out in /var/www/clients/client1/web1/web/wp-includes/class-http.php on line 876
     
  19. Skyflash

    Skyflash New Member

    FOUND!

    Seems a problem related to the address management in ISPConfig. Some website parts are locally resolved as www.websitename.biz and some other parts are resolved as /var/www/clients/client1/web1/web/.. so the wp-cron.php fails

    Is described HERE

    It seems the solution is add this directive into the wp-config.php:

    define('ALTERNATE_WP_CRON', true);

    I'm yet a little bit confused about the different path management (probably my dns mistake, but i think it is correct... i need to make a check) but this method is working
     
  20. till

    till Super Moderator Staff Member ISPConfig Developer

    But the first thing is a url while the second one is a system path. So I dont think that they get mixed up by PHP. For example the resolving of a IP can never return a system path, it will return always the domain. According to the error, its most likely a domain config issue, either in the website settings or in dns.

    How did you configure the domain in the website settings in ispconfig?

    In the domain field there should be just "websitename.biz" without www and in the outo subdomain field you should select "auto subdomain: www" to reach the domain with and without www.

    In your dns record of the zone websitename.biz, there must be a a-record for the zone itself and a a-record for the www subdomain.
     

Share This Page