• Resolved willx

    (@willx)


    Ok, first of all, I’m looking for something specific like a scheduler or something.

    My problem: I want to run a specific function (lets call it doSomething()) exactly once a day, at night (like 03:00 am).

    I was looking for something like this, and I found the function “wp schedule event”. However, in the documentation, it says “The action will trigger when someone visits your WordPress site, if the scheduled time has passed.”

    This is not what I want, the function should be called when the scheduled time has passed, regardless of whether or not a visitor visits the website.
    (That’s the main reason why I want to run this once at night, cause it will pull data from many locations and put about 70 000 records in my database, I cannot let a visitor wait 2 minutes to load the website, just cause the function is running…)

    Is this possible in WordPress?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter willx

    (@willx)

    Nevermind this, apperently the WP-Cron (built-in which wp_schedule_event also uses) makes sure the user isn’t slowed down…

    >apperently the WP-Cron (built-in which wp_schedule_event also uses) makes sure the user isn’t slowed down…

    what was your source of that info (if you don’t mind sharing!)

    ah nevermind. thanks for pointing me in the right direction!

    The reason to call wp-cron.php is because some jobs might take more time and the user requesting the WordPress page cannot be made to wait. Calling the wp-cron.php helps keep the WP-Cron function running as a separate process in the background without delaying the page load time for the user. Once the WP-Cron function starts, it continues to run until all the required jobs are completed or until it reaches an execution time as set in the server configuration.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Call function once per day’ is closed to new replies.