Support » Plugins and Hacks » Hacks » Cron job only fires if pages are visited – why?

  • I developed a plugin that upon activation (register_activation_hook()) creates a cron job. This cron job is suppose to trigger once a day. After activation of the plugin I can see the cron job to be scheduled for the “next run” at the desired time and the counter is counting down. Unfortunately, the cron job only triggers if a user is browsing to at least one page on my site.

    My question: Is there a way to make a cron job fire, even if no users accessing/browsing the site?

    Help is much appreciated as I can’t seem to find any references online.

Viewing 5 replies - 1 through 5 (of 5 total)
  • is there another anti-hack plugin ?

    you can ask your host to set up a cron for you..

    Michael

    (@alchymyth)

    Forum Moderator

    @adilali99

    please start your own thread, and provide more details with your question.

    I am just wondering why WP requires pages to be loaded in order to trigger cron jobs. I understand that the wp-cron.php is called every time a page is viewed, etc. Yet what I don’t get is why have the wp_schedule_event() function, if it still requires user interaction with the site. Doesn’t seem logical. Maybe I am missing something.

    @forensicdev:
    a ‘real’ cron would require a service / demon process running with root access. If you have root access to your host you can set up a real cron (assuming a non-windows server). The WordPress ‘cron’ reflects the knowledge that many sites have traffic pretty much every hour. So it takes advantage of this and use that to trigger it’s activity (since a web server only acts when prompted).

    So, the broken logic is simply because it is trying to work around getting ‘root’ to setup the crontab.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Cron job only fires if pages are visited – why?’ is closed to new replies.