If by “run into trouble” you mean that you are getting server or browser timeouts, I’d expect the same trouble with wp_schedule_single_event, since it is just going to run your function at some other time.
I would consider using wp_schedule_event to break the work up into chunks– say, process 500 (of your 4000 likes) every half-hour or every hour. I suppose you could do the same with wp_schedule_single_event by scheduling multiple single events but I am not sure why you would prefer that over wp_schedule_event.
Neither of those will strictly be “background” processes, though, by which I think you mean something like this.
I should also note that most of the hosts I’ve seen do not allow the kind of mass volume email that you are sending. I’d check the TOS if you haven’t already.
Related Posts:
- Which action for triggering cron “wp”or “init”?
- wp_schedule_event in a class
- WP Cron – Run Cron after evey 15 minutes at a specific time for the next three hours
- Using wp_cron with custom time interval and the register activation hook
- WordPress scheduled task is called but not executed
- Problem creating cron job wordpress
- How Do I Make WordPress Run an Event Every Day?
- How can I change the frequency of a scheduled event?
- Hourly WP schedule, do I need at least 1 visitor hourly?
- WP Cron doesn’t save or in post body
- Is there any background process that I can run from plugin without depending on page hits on a website without affecting page-load speed?
- WordPress cron running twice
- Scheduling a task using class methods
- What is minimum time interval for which a cron be scheduled?
- Will cron job run if page loaded is being served from cache?
- Use wp_set_post_terms() instead of wp_insert_post()
- Programmatically detect if wp-cron is disabled?
- How to schedule a cron job in plugin without waiting for page load request?
- How to perform a heavy and long process in cron jobs?
- WordPress daily cron is executing more frequently than once a day
- wp-cron and execution of code in is_admin() included script
- How to Trigger WP CRON at Local Timestamp?
- WP Cron being triggered but not working as expected
- wp_schedule_event() set daily, but processed every second
- Will I get an error if I try unscheduling a WP Cron scheduled task that wasn’t scheduled?
- Looking for a better way to initiate cron job
- WordPress plugin cron working only if admin is logged in
- How to make a cronjob type plugin
- wp_schedule_single_event is set correctly but sometimes not fired
- How to Run Plugin on Server Without Web Browser
- Plugin with functions inside a class & how to trigger WP CRON
- Custom recurrence not working / Wp Cron event
- How and when would I implement some code which would take data from one part of the Db and put it in another?
- WP Cron as Fast as WordPress AJAX?
- Detect each active instance of a widget
- What is the use of wp_schedule_event hook?
- Call do_action() within WordPress cronjob
- Running one-off cron jobs when WP_DISABLE_CRON is true: can I hit /wp-cron.php?
- wp cron does not run when i am not logged in to wp admin
- How to make a plugin require another plugin?
- Why does WordPress use outdated jQuery v1.12.4?
- Is it possible to reuse wp.media.editor Modal for dialogs other than media
- How do i best handle custom plugin page actions?
- Using a plugin class inside a template
- Change admin language based on user (in single-site)
- Global Objects and Public Methods
- Check for featured image in WP_Query
- Enqueue script only when shortcode is used, with WP Plugin Boilerplate
- add_filter OO with parameters
- Shortcodes, output buffering, and WordPress functions
- Auto update specifick plugin
- Get returned variable from a function to add_shortcode function
- What is the difference between current_page_parent and current_page_ancestor?
- Using the component outside the editor. select(‘core’) is null
- Tips for targeting widget dragable for WP Pointer on widgets.php page
- Any ideas how to make unit test read the theme functions.php?
- Add a panel to edit post
- Auto-Update Plugin Creating .tmp directory, not overwriting old version
- Cannot update …/tags folder in SVN Repository
- Is there a way to ensure plugin script loads before another script?
- ORDER BY wp_post custom column name in wp_query
- Verify if user is wordpress logged in from another app since wordpress 4.0
- Is it necessary to sanitize plugin options?
- PowerPress mobile media player
- You do not have sufficient permissions to access this page on a submenu
- Possible to get all posts with my shortcode?
- How to prevent someone from entering strings without making it available for translation?
- Add information to HTTP Header in WordPress Plugin
- How can I develop a plugin that generates a page dynamically
- Catching Gutenberg sidebar switch event
- Redirect in WordPress plugin
- Converting data-name editor plugin to Gutenberg plugin
- Forward an old url rewrite scheme to a new one?
- $wpdb in php 5.5
- How to Find a Gallery’s ID
- WP 3.3 makes it possible to add meta box to Category Editor Screen?
- Bootstrap within shortcode
- How to make premium plugin? I want to limit it until verification
- Undefined cache functions in my custom plugin
- get_the_tags doesn’t works?
- WordPress discards PNG file when uploading plugin file
- Does hooking into a plugin action / filter override the plugin’s function for that hook?
- Replace the WordPress Media Library Uploader
- My plugin showing “Are you sure you want to do this” on screen with a “Argument #2 is not an array in load.php’
- Cannot save settings value
- Is it possible to modify an Elated plugin portfolio-list template in such a way that it will not conflict with future plugin updates?
- Select field value not returned after saving changes
- WP Query Relations / Compare
- Page template compatibility with different themes
- Add Admin menus or submenus depending on conditions
- Refresh or redirect page after activate my plugin
- Adding class to the parent of current-post-ancestor / current-menu-parent / current-post-parent
- How do I store a custom dataset in WordPress to best take advantage of API?
- how can I insert a link on login page
- What’s wrong in the WordPress Meta Box Generator code?
- add category id to option name when adding an option on edit_category
- esc_url, esc_url_raw or sanitize_url?
- 2 Domains pointing to SIngle WordPress , issues with links
- How can I space out images when adding to a post without HTML/CSS/JS?
- How to apply a javascript code on certain parts of elementor made pages?