In one of the projects I worked on there was plugin that was automatically updating itself when an admin logs in.
Strange I know. So needed to automate things. WordPress does a check for (plugin) updates every few hours (12?)

I am sure you know know about WordPress cron that is a cool feature that runs tasks regularly or a one time task that may need more time to complete.

To list the current WP Cron hooks that have been registered you can use this command:

wp cron event list --fields=hook,next_run

 

+------------------------------------------+---------------------+
| hook                                     | next_run            |
+------------------------------------------+---------------------+
| qsandbox_awesome_check				   | 2019-02-05 01:00:00 |
| wordfence_hourly_cron                    | 2019-02-01 11:50:25 |
| mailster_cron                            | 2019-02-01 11:55:00 |
| wp_version_check                         | 2019-02-01 11:56:51 |
| wp_update_plugins                        | 2019-02-01 11:56:51 |
| wp_update_themes                         | 2019-02-01 11:56:51 |
| wp_scheduled_delete                      | 2019-02-01 11:56:59 |
| mailster_cron_cleanup                    | 2019-02-01 11:57:00 |
| wp_privacy_delete_old_export_files       | 2019-02-01 12:03:03 |
| smp_wbs_net_dbbu_hook                    | 2019-02-01 12:08:14 |
| smp_wbs_net_dbbu_hook                    | 2019-02-01 12:12:23 |
| check_plugin_updates-updraftplus         | 2019-02-01 12:33:52 |
| update_network_counts                    | 2019-02-01 12:34:29 |
| puc_cron_check_updates-updraftplus       | 2019-02-01 12:35:47 |
| puc_cron_check_updates-updraftplus       | 2019-02-01 12:35:54 |
| wp_scheduled_auto_draft_delete           | 2019-02-01 13:44:50 |
| smp_wbs_net_doody_hook                   | 2019-02-01 15:00:00 |
| check_plugin_updates-updraftplus         | 2019-02-01 16:40:30 |
| wp_scheduled_delete                      | 2019-02-01 16:40:31 |
| gravityforms_cron                        | 2019-02-01 18:47:39 |
| pmpro_cron_expire_memberships            | 2019-02-02 01:55:08 |
| pmpro_cron_expiration_warnings           | 2019-02-02 01:55:09 |
| delete_expired_transients                | 2019-02-02 05:03:03 |
| puc_cron_check_updates-updraftplus       | 2019-02-02 07:50:10 |
| wordfence_daily_cron                     | 2019-02-02 07:50:25 |
| check_plugin_updates-updraftplus         | 2019-02-02 09:12:22 |
| wp_scheduled_delete                      | 2019-02-02 09:12:23 |
| pmpro_cron_credit_card_expiring_warnings | 2019-02-06 01:55:08 |
| qsandbox_awesome_check	           | 2019-02-07 01:00:00 |
+------------------------------------------+---------------------+

To trigger WordPress to check for plugin updates you need to run this command.

wp cron event run wp_update_plugins

If you want to trigger the plugin update check for a given site in a WordPress Multisite network.

wp cron event run wp_update_plugins --url='https://example.comm/site123'

if you call this command from php you can pass the format parameter and get the data in JSON format.
--format=json

 

Related

 

Disclaimer: The content in this post is for educational purposes only. Always remember to take a backup before doing any of the suggested steps just to be on the safe side.
Referral Note: When you purchase through a referral link (if any) on this page, we may earn a commission.
If you're feeling thankful, you can buy me a coffee or a beer