WordPress Console Application (ability to excecute a custom function via crontab only)
The solution is as @Tom J Nowell mentioned to launch WP Cron via crontab (and disable it on user visits).
The solution is as @Tom J Nowell mentioned to launch WP Cron via crontab (and disable it on user visits).
Question: Will each instance try to run the same job Yes! If you have 5 machines running the same site, they’ll all try to run the cron job. It’ll be inconsistent, but if machine 1 triggers WP Cron and there’s an event ready to run, and machine 2 triggers WP Cron, then machine 2 will … Read more
WP CLI to the rescue! Instead of using php and trying to figure out the rest, install it on the server and just have your cron execute wp cron event run –due-now –path=/home/mysite_staging/www/example.com/
I can’t schedule (I don’t know how I should do it) separately CRON jobs because I had a few situations when some function was run before I have necessary data The key to doing this is scheduling the first job to run daily at the required time, and have that event create all of the … Read more
One approach (avoiding PHP timeouts) for a local Linux Cron Job (for exact timing) is creating a WP-CLI command (does not run in the browser), like: <?php /* Plugin Name: WP-CLI Foo */ function foo_command( $args ) { // Adjust to your needs … WP_CLI::success( $args[0] ); } WP_CLI::add_command( ‘foo’, ‘foo_command’ ); and the corresponding … Read more
page load is not affected […] and the //METADATA is echoed/displayed immediately? With your current setup, that is not possible. In order to display immediately, you need the data. To get the data, you need to wait. Possible solutions are: Fetch the data before (e.g. via Cron) and populate the DB with the info. -> … Read more
You can pass arguments to the wp_schedule_single_event function: wp_schedule_single_event($newdate, “one_day_before_event”, array($post->ID)); Then if you do an add_action you can say how many arguments it will receive (in this case 1). add_action( ‘one_day_before_event’, ‘some_function’, 10, 1 ); Then in your function you can access the variable: function some_function($post_id) { // Do something with $post_id }
A simple and dynamic way to use WordPress cron would be to set up an action hook for your schedule then only add scheduled events as and when you need them. The events would call a generic function and pass in your specific custom post type details through $args – add_action(‘my_schedule_event’, ‘generic_function’); function set_schedule($post_id) { … Read more
I believe by default these folders are created by user interaction, however, it’s possible that a plugin may be calling a function to create these monthly upload folders. Note that using this function will create a subfolder in your Uploads folder corresponding to the queried month (or current month, if no $time argument is provided), … Read more
For what it’s worth, I found wp-cron processes running under the Processes section in WHM. I killed them and now all wp-cron behavior is back to normal and the emails have stopped.