2

I wrote a cron script and included at the top

require_once('/home/cli6951n3/domains/mydomain.com/public_html/wp-load.php');

In wp-config.php I added this line:

define('DISABLE_WP_CRON', true);

As result I get a huge amount of errors. See text below. A lot plugins and the Themes are mentioned in the error reports. How can I solve this?

PHP Notice: Undefined index: SERVER_PORT in /home/cli6951n3/domains/mydomain.com/public_html/wp-content/plugins/wp-fastest-cache/wpFastestCache.php on line 1536

Notice: Undefined index: SERVER_PORT in /home/cli6951n3/domains/mydomain.com/public_html/wp-content/plugins/wp-fastest-cache/wpFastestCache.php on line 1536 PHP Notice: Undefined index: SERVER_NAME in /home/cli6951n3/domains/mydomain.com/public_html/wp-content/plugins/wp-fastest-cache/wpFastestCache.php on line 1537

Notice: Undefined index: SERVER_NAME in /home/cli6951n3/domains/mydomain.com/public_html/wp-content/plugins/wp-fastest-cache/wpFastestCache.php on line 1537 PHP Notice: Undefined index: SERVER_PORT in /home/cli6951n3/domains/mydomain.com/public_html/wp-content/plugins/wp-fastest-cache/wpFastestCache.php on line 1537

Notice: Undefined index: SERVER_PORT in /home/cli6951n3/domains/mydomain.com/public_html/wp-content/plugins/wp-fastest-cache/wpFastestCache.php on line 1537 PHP Notice: Undefined index: HTTP_HOST in /home/cli6951n3/domains/mydomain.com/public_html/wp-content/plugins/wp-fastest-cache/inc/cache.php on line 177

Notice: Undefined index: HTTP_HOST in /home/cli6951n3/domains/mydomain.com/public_html/wp-content/plugins/wp-fastest-cache/inc/cache.php on line 177 PHP Notice: Undefined index: HTTP_HOST in /home/cli6951n3/domains/mydomain.com/public_html/wp-content/plugins/minimal-coming-soon-maintenance-mode/framework/public/init.php on line 38

Notice: Undefined index: HTTP_HOST in /home/cli6951n3/domains/mydomain.com/public_html/wp-content/plugins/minimal-coming-soon-maintenance-mode/framework/public/init.php on line 38 PHP Warning: Cannot modify header information - headers already sent by (output started at /home/cli6951n3/domains/mydomain.com/public_html/wp-content/plugins/rdp-plugin/rdp-plugin.php:1) in /home/cli6951n3/domains/mydomain.com/public_html/wp-content/themes/Avada-Child-Theme/functions.php on line 13

Warning: Cannot modify header information - headers already sent by (output started at /home/cli6951n3/domains/mydomain.com/public_html/wp-content/plugins/rdp-plugin/rdp-plugin.php:1) in /home/cli6951n3/domains/mydomain.com/public_html/wp-content/themes/Avada-Child-Theme/functions.php on line 13 PHP Notice: Undefined index: REMOTE_ADDR in /home/cli6951n3/domains/mydomain.com/public_html/wp-content/themes/Avada/includes/avadaredux/avadaredux-framework/AvadaReduxCore/inc/class.avadaredux_helpers.php on line 69

Notice: Undefined index: REMOTE_ADDR in /home/cli6951n3/domains/mydomain.com/public_html/wp-content/themes/Avada/includes/avadaredux/avadaredux-framework/AvadaReduxCore/inc/class.avadaredux_helpers.php on line 69 PHP Notice: Undefined index: REMOTE_ADDR in /home/cli6951n3/domains/mydomain.com/public_html/wp-content/themes/Avada/includes/avadaredux/avadaredux-framework/AvadaReduxCore/inc/class.avadaredux_helpers.php on line 69

Notice: Undefined index: REMOTE_ADDR in /home/cli6951n3/domains/mydomain.com/public_html/wp-content/themes/Avada/includes/avadaredux/avadaredux-framework/AvadaReduxCore/inc/class.avadaredux_helpers.php on line 69 PHP Notice: Undefined index: REMOTE_ADDR in /home/cli6951n3/domains/mydomain.com/public_html/wp-content/themes/Avada/includes/avadaredux/avadaredux-framework/AvadaReduxCore/inc/class.avadaredux_helpers.php on line 69

5
  • What are you trying to accomplish? It's not clear from the question.
    – Pat J
    Nov 10, 2016 at 20:19
  • Does the cron script call the php executable directly? Nov 10, 2016 at 20:23
  • I try to solve these issues. The cron script is call the exectuble directly from the server.
    – Hermants
    Nov 10, 2016 at 20:39
  • Please edit your question to include the content of your cron script.
    – Pat J
    Nov 10, 2016 at 22:16
  • Those sound likes indexes in the $_SERVER array, which don't exist when run from a command line script, since those values are obtained from HTTP headers. You should look at creating your cron script in WordPress like here wordpress.stackexchange.com/questions/49927/… and then scheduling like wordpress.stackexchange.com/questions/199725/… Nov 11, 2016 at 0:14

1 Answer 1

1

You're getting Undefined index errors because you're loading the files directly and not rendered through the server. The server typically populates those values and it's actually more secure to run with less elevated privileges (through an HTTP request).

Throw your manual cron to a curl or wget -- whichever you have installed on your server.

curl -s -H "User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64)" http://YourWebsiteURL.com/wp-cron.php?doing_wp_cron

OR

wget -O /dev/null http://www.YourWebsiteURL.com/wp-cron.php?doing_wp_cron > /dev/null 2>&1

This should trigger your cron and with www privileges instead of server root access.

1
  • Thanks for the idea how to solve it, With wget it runs well. Have a nice day.
    – Hermants
    Nov 11, 2016 at 7:05

Your Answer

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

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