I need details about wp-cron. I used wp_schedule_event
for automatically sending emails.
But wp_schedule_event
is only triggered when a user visits our site.
How to make the cron run automatically?
I need details about wp-cron. I used wp_schedule_event
for automatically sending emails.
But wp_schedule_event
is only triggered when a user visits our site.
How to make the cron run automatically?
You must be logged in to post a comment.
It will run at first visit right after the scheduled time.
1.- yes, run automatically, but triggered by a visitor.
2.- it’s enough to sending email in a scheduled basis.
For a real cron behavior you can run a script using
crontab
-q: quiet (no output). Just run the script. Otherwise you will have a lot of files in your server (wget pull files)
Tip: http://www.thegeekstuff.com/2011/07/php-cron-job/
Using cpanel: http://wiki.hostbillapp.com/index.php?title=Settings:_cPanel:_Cron_job
wp_cron
does not run all the time in the background the way the name might suggest. That kind of scheduling isn’t possible for a web application like WordPress, since the WordPress script only runs when someone is viewing the site and it does not run when no one is looking. What happens instead is that when the WordPress script boots, the cron values are checked and if one is (over)due it gets executed. It may be a few minutes late or a few hours late, but that is the way it works.The wp_cron
jobs run at the first opportunity, basically.If you want to run a script when someone visits the site, you don’t really want
wp_cron
at all.wp_cron
doesn’t trigger when someone visits. It is a fuzzy timer. To run when someone visits you are going to have to think it through some. You could put a function in your theme’s functions.php but it would run on every page load, not just on the first load of the visit. You could hook towp_login
and run your function when someone logs in. You are going to have to decide what counts as a ‘visit’ first.It seems that every one has just answered the way a *nix cron should be setup. Where as the real answer should be wordpress specific. There is a setting that can be done in the wp-config.php
Now if you can configure the *nix cron like Igor Parra answered, the background and offset cron jobs will not run any more, where as the time set in the control panel or crontab will be in effect.
You need to set the cron as wel after writing functionality in file..
Refer : http://wp.tutsplus.com/articles/insights-into-wp-cron-an-introduction-to-scheduling-tasks-in-wordpress/
The real thing is always preferable, but it can be done in WordPress (pure PHP):
http://pippinsplugins.com/improved-cron-plugin-review/