First, you’ll have to determine an average time to execute your job. Run it once every minute, five times. Use error_log('Start');, and error_log('End'); to mark the start time, and the end time. Take an average of all five results and round it up to full seconds. Prepare your job to execute its logic 6 times in a loop:
$avgExecTime = 3; //replace this with the average execution time from your tests
$sleepTime = 10 - $avgExecTime;
for($i = 0; $i = 5; $i++) {
//
// your logic goes here
//
if($i < 5)
sleep($sleepTime);
}
Now, you can set your system cron to run this job every minute, forever.
Note: make sure that your job’s average execution time is less than 10 seconds. If it is not, increase the frequency to 15 seconds, and modify your job accordingly.
Related Posts:
- Uncaught Error: Call to undefined function wp_generate_attachment_metadata() @ wp-cron
- How ( and mostly at what time ) can i prevent the alternate cron from running?
- How to periodically scrape and cache strings from remote txt files. – My First Plugin
- How does task scheduler plugin implements cron that is not dependent on page load request? [closed]
- Setup wp_schedule_event within a custom plugin
- WordPress cron job running more than once
- i need to make custom cron_schedule with custom interval time as a parameter into a custom payment gateway plugin wordpress
- Cron: Update four post at Hour
- Activate Plugin Automatically After Set Time
- Better way to run heavy scripts using WordPress database
- WordPress Cron function is not working
- Adding custom cron_schedule prior to wp_schedule_event
- Cron Job not working
- What are the differences between WPINC and ABSPATH?
- Problems with autoloading classes via sp_autoload_register / maybe interfering WP-specific autoloader
- Using require_once in a Plugin?
- How do I email a new page password to somebody every month?
- How to Loop Plugin Option Field Set?
- Updating WooCommerce variable product stock issue
- Rename existing old uploaded images containing accented French characters (not during upload)
- How to Create a Directory in a Plugin Folder?
- Create plugin that works in background
- Checking for user role in a custom plugin
- HELP: Integrating WP with raw PHP code once published button is hit
- Loading class files via autoload method
- I would like to use create a function in my custom plugin to tell WP to use a different header
- Getting media library popup in custom plugin admin page
- action-scheduler vs wp-background-processing
- Does wp-cron runs all tasks scheduled at same time together or one after other?
- jQuery function didn’t work in my plugin
- Sanitizing, Validating and Escaping in WordPress (Plugin)
- Escape when echoed
- Scope for PHP Variables Assigned in functions.php or a plugin
- Why is wp-cron only executing on page visit?
- Plugin Development sqlite or WordPress’ database
- WooCommerce get_price returning wrong price when used via ajax
- Open Post Thumbnail in New Child Theme File in WordPress
- Redirecting to home page after login as custom role WordPress
- Add keywords meta to index.php page
- Pulling data from custom plugin settings using PHP shortcode and Javascript
- wordpress plugin is not activating from widget
- Does using WP-cron make the site slower for the user?
- Creating a custom post type, adding custom meta fields, preventing all future editability of posts of this type
- How to fetch products with the price in a page on woocommerce using a form or live search with php
- Creating a Callback URL for WordPress Woocommerce to update Order Status
- How to make a implement queue for scheduling tasks in WordPress?
- What are the specifics of WordPress development I need to know? [closed]
- How to replace WordPress Media Upload Window with user’s device window?
- How to create a custom post type that contains another custom post type?
- WordPress get_avatar function not correct working
- Check if variable is set in filter
- Add User Role: Pre-saved in User-Meta [SOLVED]
- Plugin onclick button activate other plugin
- I receive taxonomy id
- How to create plugin/ page that reads from database
- How WordPress core manage the plugin installation
- Asynchronous request in wordpress
- Make plugin php file called directly aware of WordPress?
- Next Previous Post in wordpress with previous / next link with title?
- Different registration form for different roles
- Apply html elements in php statement
- WordPress Post HTML after Posting
- Settings options not showing up on Sub Menu page in WordPress plugin
- can’t unzip file
- Allow a particular user to access a particular plugin?
- Change plugin descriptions
- The Build menu theme is frozen with the wordpress theme
- How can I translate something in my class constructor of my plugin in WordPress?
- Define global variable in theme file and call that variable in plugin file
- How to translate to spanish wordpress hardcoded content/files?
- update_post_meta is not working for me when I use e.preventDefault for update button
- working code, not working – Plugin Dev
- SimpleXML is not working with xml response from external api
- How to use Datatable with Ajax when creating plugin on WordPress?
- Multiple image selection custom widget
- Prefix WordPress Taxonomy Tags With Hashtag Symbol Like Twitter
- Change Woo Custom Endpoint Titles from a Plugin
- Showing how many times is plugin activated or deactivated
- register_activation_hook doesn’t fire at all
- Plugin communication between sites that use it?
- My ajax request don´t work and return 0
- Form tries to download a file on submit
- Populate select option with JSON file
- insert multiple entries in database using a loop issue
- Theme editor removes backslashes
- Plugin Hook: Get posts
- How to get site homepage from plugin?
- Undefined variable _POST
- Unable to show 4 products in a row
- How to add custom html to the Media > Attachment Details modal?
- Displaying Category Feature image on loop
- How to override plugin function in code snippets WordPress
- How to create a “Most Popular” & “Latest” TAB in WordPress
- Use inline callable for hooks and filters
- Error in using ‘admin_enqueue_scripts’ action through a class
- Mixed results with is_page() WordPress function, when using $this, or self
- REST API – filters not working inside plugin class
- WordPress site server getting blocked due to resource abuse
- WordPress “wp cron event run” as Siteground cron job
- Custom Search Function in WordPress Returns No Results