Q:

Use Cron to modify posts via sql

Hi to all I need to run this twice a day:
UPDATE wp_posts SET post_content = REPLACE ( post_content, '[img]', '<img src="' );
UPDATE wp_posts SET post_content = REPLACE ( post_content, '[IMG]', '<img src="' );
UPDATE wp_posts SET post_content = REPLACE ( post_content, '[/img]', '" />' );
UPDATE wp_posts SET post_content = REPLACE ( post_content, '[/IMG]', '" />' );
UPDATE wp_posts SET post_content = REPLACE ( post_content, '[b]', '<strong>' );
UPDATE wp_posts SET post_content = REPLACE ( post_content, '[B]', '<strong>' );
UPDATE wp_posts SET post_content = REPLACE ( post_content, '[/b]', '</strong>' );
UPDATE wp_posts SET post_content = REPLACE ( post_content, '[/B]', '</strong>' );

How can do it? I don't want to run it manually and I can't do it each time a post is published because I'm running a MU website and my authors are too lazy to modify their code from bbCode to HTML.
I'm using cPanel so I can add a CronJob easily if you teach me how to do it.
Thanks to all!

A:

Creating your own schedules is a little messy (because they need to be persistent and stored in database), but it is quite easy to hop on one of the native schedules that run twice a day.
add_action( 'wp_version_check', 'my_function' );

function my_function() {

    //stuff
}

As for running actual queries you should use $wpdb for that.

