WordPress function, Run using Crontab

define('DISABLE_WP_CRON', true);

This line disables the default behaviour of WP Cron. Which is being triggered by a user that visits the site. This is bad for a couple of reasons (nobody might visit, tasks are started via apache handler instead of PHP CLI, …).

Now, if you have disabled it, you need another way to run WP Cron. Using crontab you could add an entry like so

*/5 * * * * php /absolute/path/to/wordpress_instance/wp-cron.php

Now wp-cron.php will run every 5 minutes via PHP CLI. This way your scheduled tasks will still run.

If you disable the default cron and don’t have an alternative as mentioned above, various WordPress functions may fail to execute!


If you want to run a specific task once per day, you can wp_schedule_event() with the recurrence being daily.