1

A .Net developer, I have not yet done any WordPress plugin development, and would like some basic details/starting points for the following.

As a part of a WordPress plugin, is it possible to create a polling daemon to kick off an intermittent process (say, every two hours) - it could really do anything like database look-ups.

The functionality would be similar to a Windows service that operates in the same matter.

Is it possible to create this functionality as a part of a plugin, or would this require some server-side implementation?

Thanks.

-- UPDATE --

In researching the wp_schedule_event I see that it is an event executed whenever someone visits your site. However, for sites with little traffic, this may not be optimal, but a possible solution?

ElHaix
  • 12,846
  • 27
  • 115
  • 203

1 Answers1

0

Yes this is possible. But that would also require WP to have cron-access to the server. The cron-job would work on the intervals on your plugin's script. Similar solution is in the tutorials at nettuts.com on WP plugin development.

Lenin
  • 570
  • 16
  • 36
  • So would there be implementation issues for widespread public deployment? – ElHaix Jun 06 '13 at 15:08
  • Nope, usually servers running Wordpress have the cron/services to be settable. Will you be hosting on *nix servers or windows? – Lenin Jun 06 '13 at 15:11
  • It could be either, as I would have no control on the server environment where someone installs the plugin. See my update above. – ElHaix Jun 06 '13 at 15:11
  • Yeah plugins like that has the functionality you are looking for. But you need to work on the cron-event, not the visit event. – Lenin Jun 06 '13 at 15:14
  • Just looked at it. It also has the hourly event setter. So, dependency over the cron is eliminated. – Lenin Jun 06 '13 at 15:15
  • 1
    Yeah, but that only executes if a page has been visited and the required time has elapsed. There could also be other reasons for it to fail: http://wpdailybits.com/blog/replace-wordpress-cron-with-real-cron-job/74 – ElHaix Jun 06 '13 at 15:30
  • Exactly, if you need it to work independent and periodically you'd need real cron/service. – Lenin Jun 06 '13 at 15:45
  • Alright, so back to the original question, I suppose - if I need real cron/service capability, is it achievable by way of a WordPress plugin. Or put a different way, is it feasible to create a cron job/service on a server during a WP plugin installation on a shared server? I'm guessing hosting companies may not allow this, but some hosting packages do provide cron accessibility. – ElHaix Jun 06 '13 at 17:00
  • Yes possible. Most hosting provides the cron access. And the link you shared above has the necessary information on how to setup such real cron. – Lenin Jun 06 '13 at 17:01