You could use WordPress’ pseudo-cron and wp_schedule_single_event
.
<?php
// add the action.
add_action('wpse71941_cron', 'wpse71941_long_running');
function wpse71941_long_running($args)
{
// might need to call `set_time_limit` here
set_time_limit(0);
// do long running stuff here
// return normal time limit
if($l = ini_get('max_execution_time'))
set_time_limit($l);
}
// schedule the event for right now
wp_schedule_single_event(
time(),
'wpse71941_cron',
array('args' => 'for', 'callback' => 'function')
);
Not sure if you need to mess with time limit. WP does call ignore_user_abort
at the top of the cron script.
Related Posts:
- Uncaught Error: Call to undefined function wp_generate_attachment_metadata() @ wp-cron
- Schedule WordPress Auto-Updates to only run during business hours
- How to make sure a wp-cron job runs
- How do I email a new page password to somebody every month?
- What happens when wp_cron is deactivated in WordPress?
- Posts wont expire
- Custom interval is not working
- Cron Job not working in plugin
- How to use wp-ajax in wp-cron
- wp_schedule_single_event function not working
- How ( and mostly at what time ) can i prevent the alternate cron from running?
- action-scheduler vs wp-background-processing
- Remove obsolete plugins artifacts from database tables
- Why is wp-cron only executing on page visit?
- How to periodically scrape and cache strings from remote txt files. – My First Plugin
- Cron job not firing
- How make a php script run only with wp-cron
- Does using WP-cron make the site slower for the user?
- wp_schedule_single_event not working: cron job is triggered but nothing gets executed
- How does task scheduler plugin implements cron that is not dependent on page load request? [closed]
- How to make a implement queue for scheduling tasks in WordPress?
- Automatic plugin updates not working
- Cron Job not working in plugin
- Setup wp_schedule_event within a custom plugin
- How to set intervals in cron jobs?
- get_edit_post_link() not working on wp-cron
- get_users(); Is an Undefined Function When Used in Cron Job
- Switch from wp-cron to a server cron job
- What causes wp_schedule_single_event to fire off?
- 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
- Save log for imports in WordPress database – options-table, custom post type or other place?
- Cron: Update four post at Hour
- Activate Plugin Automatically After Set Time
- reminder wp_schedule_event
- get_posts query results out of order but shows correct in php snippets plugin
- Scheduled cron event removed from list automatically after sometime
- WP_CRON issue with UTC and local time
- Better way to run heavy scripts using WordPress database
- wp_schedule_event function reference
- WordPress Cron function is not working
- WordPress crob job performance
- How to customize ‘recurrance’ of’ wp_schedule_event’?
- Adding custom cron_schedule prior to wp_schedule_event
- Using a Cron Job to dynamically populate a field ONCE, and then making the field blank the next time someone visits page
- Plugin Hooks Not Shown in WP Cron Jobs
- Running a function using Crown WordPress on one day a week, for example, Mondays of every week
- WooCommerce store with ~30,000 products [closed]
- Is there any record of installed plugins in the database?
- Being notified when some YouTube video in some post becomes unavailable
- Is it possible to run plugin code when a multisite blog is deleted?
- plugin wants to update to wrong plugin
- Why is this custom taxonomy showing in the database?
- Where is the source code that makes the “all” array grabs filters in the $wp_filter?
- How can I change plugin to give access to editor user role?
- How to include and use custom class files in plugin?
- Change settings of get_post_type_object
- Embed a Google Sheet as you view it in a separate tab?
- How can I check if on specific plugin generated page or child
- Error with third-party package: “Updating failed. Error message: The response is not a valid JSON response.” [closed]
- Transition from the pro version to the free version of the plugin
- There is any way to remove post-format filter? [closed]
- Trying to fix form resubmition with PRG (Getting error: Cannot modify header information – headers already sent by)
- Retrieving Meta from Image Attachment
- Problems With WP Bannarize Plugin [closed]
- How to create a child/addon plugin
- How to secure the release of WordPress plugins / avoid copying plugins?
- how to force tag page layout to use same as search layout?
- WordPress Users authentication with Java Application
- how to make wordpress plugin from PersianWebToolkit? [closed]
- Limit WP code scope into plugin
- Custom search search does not work?
- WordPress custom plugin that uses woocommerce enabled payment gateway for payment [closed]
- Execute a function when the entire page is displayed
- Cannot read properties of undefined (reading ‘firstChild’) using photoswipe in product page
- Find Plugin by file name
- Creating an admin button that when clicked shows a popup form
- Add an action based on custom post meta field
- How to hide an option from dropdown in filter module
- how to create user profile pages and display them based on users roles
- How to change “Read More” text?
- Woocommerce – Change variations output
- how do i fixe Page Builder on a custom page?
- WordPress ajax error 400 bad request for sending data to remote site [duplicate]
- wp_enqueue_scrpts seems not to get called
- How to Create Custom Dashboard for my Laundry Website?
- Warning: Illegal offset type in /var/www/html/wp-includes/option.php on line 1924
- How to create a WordPress sandbox on a live server for website development?
- What is a good way to test that plugin upgrades have completed properly?
- get post excerpt by query
- Advanced Custom Fields (ACF) Plugin – Random Image in Sidebar
- Deleted plugins displays error message
- __FILE__ in WordPress plugins
- Looking for a related post plugin which slides-in like the one at inc.com does [closed]
- Woocommerce Product Add-ons – Auto-select first option
- Sync roles across several plugins
- Identifying Plugins Based on Tables [closed]
- How can I save the selected page in the dropdown after anyone clicks on Save Changes?
- How can I display an attribute from each post inside foreach($latest_posts1 as $post )
- Wrong block appender button showing