Dynamic name of cron event

So no, I can’t see a way to grab the name of your action. However, you can pass arguments to your callback: $blog_id = get_current_blog_id(); $cron_name=”import_blog_posts_in_network_daily_”.$blog_id; if ( !wp_next_scheduled( $cron_name) ) { wp_schedule_event( time(), ‘daily’, $cron_name, array($blog_id) ); } add_action( $cron_name, array($this, ‘import_blog_posts_in_network’) ); /* public function import_blog_posts_in_network($blog_id) { // do something for blog $blog_id … Read more

escaping double quotes and percent signs (%) in cron

You have to escape the % signs. They have a special meaning in crontabs: man (5) crontab: Percent-signs (%) in the command, unless escaped with backslash (\), will be changed into newline characters, and all data after the first % will be sent to the command as standard input.

WordPress cronjob get scheduled but function does not run

I believe you need to use wp_get_current_user() (see https://codex.wordpress.org/Function_Reference/wp_get_current_user ), which will return the current WP user information as an object. From there, you can get the user name (or other parameters). From that page, this example should get you started: $current_user = wp_get_current_user(); /** * @example Safe usage: $current_user = wp_get_current_user(); * if ( … Read more

WordPress Cron job, 302 response

The problem here is a mistake regarding how to schedule a cron event, lets begin with: wp_schedule_event(time(), ‘hourly’, ‘my_schedule_hook’, $args); wp_schedule_event(time(), ‘hourly’, ‘update_user_hours’); Here you are telling WordPress to fire the update_user_hours action/event on an hourly basis. You then hook into this to fire a callback: add_action(‘update_user_hours’, ‘do_this_hourly’); But then, instead of declaring do_this_hourly, for … Read more

Prevent duplicate cron jobs running

There are a couple of programs that automate this feature, take away the annoyance and potential bugs from doing this yourself, and avoid the stale lock problem by using flock behind the scenes, too (which is a risk if you’re just using touch). I’ve used lockrun and lckdo in the past, but now there’s flock(1) … Read more

Cron job for let’s encrypt renewal

Monthly is not frequent enough. This script should run at least weekly, and preferably daily. Remember that certs don’t get renewed unless they are near to expiration, and monthly could cause your existing certs to occasionally be expired already before they get renewed. The name of the program is certbot, which was renamed from letsencrypt. … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)