Cron jobs in wordpress, without wp scheduler
-
Hey guys, I want to setup a cron job on my server (via crontab) that hits a script which requires the wordpress-environment to be loaded in order to work.
My current solution looks like this: I’m triggering a php script which requires ‘wp-load.php’ and kicks things off via triggering a hook using
do_action('stuff_that_happens_when_crontab_hits')
to which the actual code that needs to be executed listen within aadd_action('stuff_that_happens_when_crontab_hits', 'the stuff')
of course. I also disabled the cron implementation of wordpressdefine('DISABLE_WP_CRON', true);
The crontab entry looks like this:
0 * * * * /var/www/wp/mywpcron.php
This is the file that gets hit by crontab:
#!/usr/bin/php <?php if (php_sapi_name() !== "cli") return; require 'wp-load.php'; do_action('stuff_that_happens_when_crontab_hits');
Does this seem legit or am I overseeing any negative repercussions? Any input would be grandly appreciated!
- The topic ‘Cron jobs in wordpress, without wp scheduler’ is closed to new replies.