While the idea that you are “developing some scrapping plugin” is sketchy and off-putting, the general question is “How do I fire code using system cron jobs?” and that is a valid question.
You don’t need to jump through hoops to load WordPress. Set up an AJAX API callback…
function fire_cron_job_wpse_144051() {
// fire your code
die();
}
// add_action('wp_ajax_fire_cron', 'fire_cron_job_wpse_14405');
add_action('wp_ajax_nopriv_fire_cron', 'fire_cron_job_wpse_14405');
… and have your system cron job make a request to //example.com/wp-admin/admin-ajax.php?action=fire_cron
. Note that fire_cron
is the trailing part of the two action hooks. You can set that to whatever you like.
Related Posts:
- How do I log plugin (cron) actions?
- Cron firing my function everytime wp-admin is visited
- How Do I Make WordPress Run an Event Every Day?
- get_posts / WP_Query Memory size of 134217728 bytes exhausted
- Hourly WP schedule, do I need at least 1 visitor hourly?
- Scheduled event does not run at midnight
- 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
- Will cron job run if page loaded is being served from cache?
- Loading WordPress Admin Environment
- How to schedule a cron job in plugin without waiting for page load request?
- Problems with cron
- How to Trigger WP CRON at Local Timestamp?
- Plugin with functions inside a class & how to trigger WP CRON
- WP Cron as Fast as WordPress AJAX?
- Best place to keep files that are called by cron jobs?
- What is the use of wp_schedule_event hook?
- Running one-off cron jobs when WP_DISABLE_CRON is true: can I hit /wp-cron.php?
- How to include PHP files in plugins the correct way
- Prevent network activation of plugin
- How are bulk actions handled in custom list table classes?
- Get list of scripts / styles and show file which enqueued them
- WordPress updates defined vs add_filter?
- Creating Settings Page with dropdowns for Plugin
- Empty POST data on server on AJAX request using Angular $http
- Custom Nav Menu items default to ‘menu-item-type’ => ‘custom’. How to make a “page” menu item?
- Custom attachments uploader code. Almost there!
- $wpdb->insert is changing a value
- What are the default WordPress password requirements?
- Can I get all options using the option group id? [closed]
- Actions or filters fired when data is saved in a custom table
- Implementing namespaces in plugin template
- How to get current page name in my wordpress plugin
- Conditional add_filter?
- Use register_taxonomy() in register_activation_hook()
- The plugin generated 80 characters of unexpected output!
- How to update/auto-update my private plugin? [duplicate]
- How to use WP default post list tables in a plugin?
- Calling apply_filters on non-documented hooks
- Use of global variables within plugin [closed]
- Add Additional File Info (jpeg compression & file size) settings to Edit Images Screen
- Sensible location for IPN Callback script
- Plugin activation error due to unexpected output
- WordPress Admin Post Type Table Class Filter Hook
- How to get the ID of the currently logged in user?
- “You do not have sufficient permissions to access this page” upon accessing my newly created plugin page
- Extend a class plugin
- Using a Shortcode to Replace Themes Stylesheet?
- Retrieve contents/page names of various pages for use in a plugin
- Slow WP_query due to nested wp_query. Need Suggestions
- How to modify product page for Jigoshop
- Is @wordpress/env locked to node v14 or can I also use node v16?
- How does task scheduler plugin implements cron that is not dependent on page load request? [closed]
- How wp-cron can run in background if PHP is single threaded?
- what is the standard ulr for wordpress plugin development?
- Create a custom capability to allow an ‘Editor’ to edit only ‘Subscriber’ users
- global $current_user not current user
- What is the proper way to get logged in user id in a plugin?
- WordPress Plugin Activate / Deactive Failing
- How can I add a simple custom field to my plugin?
- Ajax is not working in a loop
- Custom Plugin – CSS works, JS doesn’t
- Inserted double quote when prepending to the_content
- unable to wp_enqueue_script(‘suggest’);
- Plugin development – loading Javascript and Flash
- update_post_meta doesnt update template
- Update variable value via add_filter
- Setting global block attribute value
- Plugin custom post template; without overriding all posts
- Run uninstall.php if a checkbox is checked from settings page
- Gravity Forms Anchor only on Front Page?
- How to set a header in wp_safe_remote_get()?
- Multiple page plugin settings
- sanitizing/escaping plugin options
- how to get the top 10 popular blogs
- can’t access some WordPress function from my plugin
- Set page to draft on plugin deactivation
- script seem not load with use wp_enqueue_script
- Do I lose translations when I change my Text domain for my plugin on wp.org?
- Transform internationalized plugin into internationalized mu-plugin?
- Override woocommerce loop-start.php from theme using plugin?
- Get value of custom checkbox from Gutenberg sidebar in plugin
- Pre-populated WooCommerce checkout fields: dropdown fields issue
- jQuery dependent script ignores $in_footer bool and doesn’t work in header
- Hiding class namespace from plugin’s extensions
- Relational / Associate tables using native WordPress functionality
- Pull commentdata for pre_comment_on_post from comment_post_ID
- Woo-commerce: Adding additional page sections using a child theme
- Get the post ID only off single page
- How to get html tag ids from template?
- Bootstrap collapse in custom WordPress widget
- Page reload occurs before request finishes
- PHP Fatal error when using plugin_basename
- How to Rewrite WordPress URL for a Plugin
- What does $_REQUEST[‘redirect_to’] do?
- How to Prove Ownership of plugin [closed]
- how can a plugin return an error message on activation?
- Declaration of mandoe_menu_walker::start_el(&$output, $item, $depth, $args) must be compatible with Walker::start_el(…)
- Reading the inside of
- WordPress, GIT, Renamed Plugin Dir + files – Working Code now Broken [closed]