WordPress: Cron locking and Queue

Simple Cronjob Walker Create a CPT cronjob for your cronjobs. Add the relevant post meta data (action, last_executed,… and whatever you need) Create a walker function function my_cronjob_walker() { $args= array( ‘post_type’ => ‘cronjob’, ‘posts_per_page’ => 1, ‘meta_key’ => ‘last_executed’ ‘orderby’ => ‘meta_value’, ); $cronjob = new WP_Query($args); if ($cronjob->have_posts()) while ($cronjob->have_posts()) { $cronjob->the_post(); // … Read more

Remove Featured Images from Posts Older Than a Certain Date

I think you might be jumping the gun with actively discarding the data here. What if next month trolls go away, you change your mind, and want all those featured images back? I would just suppress them on front end by editing template and making thumbnail output conditional or filtering API with something like this: … Read more

WordPress crob job performance

No, The action will trigger when someone visits your WordPress site, if the scheduled time has passed. So if there no visitors crob job will not be triggered. In your case, it is better if you can run server cron job. Performance issue depend on the function you need to run as a cron job.

WordPress Cron function is not working

Are you constructing the class properly? Is the file writable? Do you need the interval or can you add the scheduled item if it doesn’t exist. This example is working, and sets an event 10 seconds into the future. wp_schedule_event( time() + 10, null, ‘ga_order_syn’ ); class CronTest { function __construct() { add_action( ‘init’, array … Read more

I want to write something that restarts the httpd service when my apache server dies

You need something like this: #!/bin/bash #test-httpd.sh client=”yourname” mailboxes=”[email protected]” # write to that file monitorfile=”/var/www/html/monitor.php” #empty monitor.php > $monitorfile APACHE=`/bin/pidof httpd` echo $APACHE if [ “$APACHE” == “” ] then echo APACHE_FAILURE | mail -s “$client””: CRITICAL : APACHE FAILURE !!!!” $mailboxes #trying to restart it /etc/init.d/httpd stop /etc/init.d/httpd start echo -e “apache:FAIL\n” >> $monitorfile … Read more

Can I run a slow action in a seperate thread?

Techcrunch has released a library to spawn an asynchronous task within WordPress. https://github.com/techcrunch/wp-async-task Essentially, you can take any process that is triggered by an action hook, and you can defer the processing on that hook to run asynchronously. You extend the class to define which action you are triggering and a couple of functions to … Read more