Run cronjob with browser request

You’d be better off using the wordpress API: function wp_register_cron_endpoint() { register_rest_route( ‘crons’, ‘/run_cron’, array( ‘methods’ => ‘GET’, ‘callback’ => ‘run_crons’ )); } add_action( ‘rest_api_init’, ‘wp_register_cron_endpoint’ ); function run_crons(){ /*** Do whatever you want ***/ } Then you can hit http://example.com/crons/run_crons and you’ll A)Trigger wp_cron based on the wp_load and B) Do whatever you want … Read more

Regenerating array key for wp_schedule_event args

So what I came up with, which seems to work is the following: This function will search by the user id and find the corresponding cron job function search_user_cron( $hook, $user_id ) { $crons = _get_cron_array(); foreach( $crons as $timestamp => $cron ) if( isset( $cron[$hook] ) ) foreach( $cron as $jobs ) foreach( $jobs … Read more

Cron jobs repeating themselves

The wp_schedule_single_event function in cron.php (http://core.trac.wordpress.org/browser/tags/3.7.1/src/wp-includes/cron.php#L0) has a comment which says: // don’t schedule a duplicate if there’s already an identical event due in the next 10 minutes So I’d say that no it won’t trigger lots of calls for earlier in the day.

Pages for Cron use Only?

You could use php_sapi_name(). See this demo lifted from the developer docs <?php $sapi_type = php_sapi_name(); if (substr($sapi_type, 0, 3) == ‘cgi’) { echo “Your are probably a human”; } else { echo “You are probably not a human”; } ?> You could just apply this kind of conditional at the start of your script.

setting up a wp cron job

It depends what you mean by “I want the test.php file to be called not earlier then a specific time each day”. Setting up a cron job is very straightforward, you just need to simply do: <?php register_activation_hook( __FILE__, ‘prefix_activation’ ); /** * On activation, set a time, frequency and name of an action hook … Read more