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
- WordPress “wp cron event run” as Siteground cron job
- Cron Job not working
- Which approach for managing automatic updates would be more robust?
- Where can I sell WordPress themes and plugins? [closed]
- Change success message in plugin Theme my login
- Extension preview disapeared since WP 4.5.2
- Good tools for locating hooks in a wordpress page/admin interface/blog post?
- How to write ‘safe’ plugins? [closed]
- Gutenberg Block: Objects are not valid as a React child (found: [object HTMLDivElement])
- How does WooCommerce store products / product variations? / Free Script to import product variations? [closed]
- How to create Repeater fields using Advanced Custom Fields?
- rms_unique_wp_mu_pl_fl_nm.php
- WordPress CMB2 – Run function on save
- Woocommerce email template customization [closed]
- Why is my staging subdomain not sending wordpress_logged_in cookies?
- Custom REST API endpoint returns rest_no_route when called via wp-json permalink
- Register Page Template from Plugin
- Making a plugin only available on the front-end for the logged in super admin
- Nonce failing on form submission
- Blog titles from WP blog on plain html site?
- How to Exclude Files in Sub-Folders from WP Plugin Editor List?
- Unable to delete custom post types, confusion around capabilities
- What’s causing this error? “Warning: Invalid argument”
- How to create a post with next buttons
- How to notify wordpress instalation about my plugin update?
- Plugin onclick button activate other plugin
- How to override the Buddypress bp-members folder’s file?
- What is it and from where it is loaded?
- Site shows URL instead of “meta title” after deleted few plugins (not any SEO plugin was deleted)
- BuddyPress activity on edit post for a CPT
- Ajax Call in page theme not working?
- Adding featured image to posts created by a plugin
- wp redirect 301 not working in wordpress page
- Yoast SEO Plug In and my Theme duplicating code. Need some feedback on what to do? [closed]
- Advanced video gallery plugin needed [closed]
- Displaying URL Based on User Input from a Form W/in a Dashboard Widget
- Is there any plugin to show number of clicks on the link?
- how to resubmit a submitted form with gravity forms plugin
- problem disabling plugin only for mobile
- WordPress hide post from custom post-type on a single page
- Installation failed: 504 – Gateway Timeout
- Create survey that redirects to sidebar menu customized to answers
- Uploading images to custom table
- How can I refresh the plugins cache manually?
- WordPress on shared server Plugin not working
- How save plugin options array in select box
- How to install jquery dotdotdot plugin for WordPress?
- Plugin Translation project not found
- Manually return false for function_exists
- New admin account cant access plugins.php
- How to add plus minus button on Input Quantity box Woocommerce? [closed]
- WordPress Plugin translation not working EN To FR
- Custom page template from plugin does not work with pre-installed themes in WordPress 6.6.1