Title: php error on cron
Last modified: March 31, 2021

---

# php error on cron

 *  Resolved [jnz31](https://wordpress.org/support/users/jnz31/)
 * (@jnz31)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/php-error-on-cron/)
 * ciaoo.
    i set up a cronjob and it throws following error:
 *     ```
       Notice: Undefined index: REQUEST_METHOD in /xxx/plugins/wp-rest-cache/includes/api/class-endpoint-api.php on line 171
   
       Notice: Undefined index: REQUEST_METHOD in /xxx/plugins/wp-rest-cache/includes/api/class-endpoint-api.php on line 297
       ```
   
 * maybe $_SERVER is not set at all? maybe it is just my environment/setup. my cronjob
   reads as follows:
    `/usr/bin/php /xxx/wp-cron.php` any clues?

Viewing 1 replies (of 1 total)

 *  Plugin Author [Richard Korthuis](https://wordpress.org/support/users/rockfire/)
 * (@rockfire)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/php-error-on-cron/#post-14268125)
 * Hi [@jnz31](https://wordpress.org/support/users/jnz31/)
 * Thank you for using our plugin!
 * The reason this is happening is because you are calling the wp-cron.php script
   incorrectly. You shouldn’t be executing it via php directly but instead be calling
   it via a url, see: [https://developer.wordpress.org/plugins/cron/hooking-wp-cron-into-the-system-task-scheduler/](https://developer.wordpress.org/plugins/cron/hooking-wp-cron-into-the-system-task-scheduler/)
   
   Another option if you want to use a CLI command is to use WP CLI (if that is 
   installed on your server, or if you can install it). You can use the `wp cron
   event run --due-now` command, see: [https://developer.wordpress.org/cli/commands/cron/event/run/](https://developer.wordpress.org/cli/commands/cron/event/run/)
 * By the way, these are notices, no actual errors, nonetheless I am adding it to
   our todo list to prevent these notices from happening when the `$_SERVER['REQUEST_METHOD']`
   isn’t set.

Viewing 1 replies (of 1 total)

The topic ‘php error on cron’ is closed to new replies.

 * ![](https://ps.w.org/wp-rest-cache/assets/icon-256x256.png?rev=3328849)
 * [WP REST Cache](https://wordpress.org/plugins/wp-rest-cache/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-rest-cache/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-rest-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-rest-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-rest-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-rest-cache/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Richard Korthuis](https://wordpress.org/support/users/rockfire/)
 * Last activity: [5 years, 2 months ago](https://wordpress.org/support/topic/php-error-on-cron/#post-14268125)
 * Status: resolved