WordPress.org

Ready to get started?Download WordPress

Forums

Cron help in codex? (5 posts)

  1. drmike
    Member
    Posted 7 years ago #

    Greets:

    Just wondering if there was any write ups within codex or elsewhere about how to use wordpress's built in cron settings. I didn't find anything when I did a search except for Skippy's plugin.

    Like how to add stuff in, etc.

    Thanks,
    -drmike

  2. cb2206
    Member
    Posted 7 years ago #

    Hi,

    I also like to know whether there is any documentation available for the build-in cron functionality of wordpress.

    Did you find anything?

  3. drmike
    Member
    Posted 7 years ago #

    Nope. Came back to ask again actually.

  4. Samuel Wood (Otto)
    Tech Ninja
    Posted 7 years ago #

    There's no actual documentation been written yet, but it's pretty simple. Just have a look through the functions in wp-includes/cron.php. You don't need to know the function details, the names are fairly obvious.
    These are the only functions you'll ever need to use:

    wp_schedule_single_event() - Schedules a one time job
    wp_schedule_event() - Schedules a recurring job
    wp_unschedule_event() - Remove a particular job
    wp_clear_scheduled_hook() - Remove a job and any other job calling that same hook (easiest way to remove a job)
    wp_next_scheduled() - Finds out when a particular job is next scheduled to run

    There's others, but you probably won't need to use them.

    Basically, these let you define jobs. At the time that the job is scheduled to run, it will call an action hook and arguments that you specify. You add your actions to that hook, which makes it call your functions, which run and do whatever you want them to do.

    The only thing you have to be careful of is to delete your jobs when you're not using them. So if you write a plugin, make sure to include a deactivation trigger that will remove your jobs using wp_clear_scheduled_hook(). Otherwise they hang around and leave a mess.

    One time jobs clean themselves up. Recurring jobs get rescheduled after every run. So an hourly job, for example, will have the next entry in there and when it runs, that entry gets removed and another one gets scheduled for an hour later. That sort of thing. This happens automatically, you don't have to mess with it.

  5. benzelf
    Member
    Posted 6 years ago #

    I need a cronjob help, I´m bad in computers and English, who like to help me anyway.

    BEN

    ben@jemaca.be thanks

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags