WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Real CRON set up . (2 posts)

  1. santosh.sahoo
    Member
    Posted 3 years ago #

    Hi,

    I thought this would be the bast place to get some doubts cleared.
    Here's my question.

    if ( !wp_next_scheduled('my_task_hook') ) {
        wp_schedule_event( time(), 'hourly', 'my_task_hook' );
    }
    
    function my_task_function() {
         wp_mail('example@yoursite.com', 'Automatic mail', 'Hello, this is an automatically scheduled email from WordPress.');
    }
    add_action('my_task_hook', 'my_task_function');

    The above code is to schedule a cron task hourly.
    Then i use

    /usr/bin/wget -O - -q -t 1 http://www.yourdomain.com/wp-cron.php

    and set it in plesk to run it every hour.
    I have also wrote define(‘DISABLE_WP_CRON’, true) in my wp-config.php
    My actual question here is :
    Do i have to set the wget command to run every hour , if i'm setting the schedule as hourly in my wordpress code .??
    Similarly , if i have to run the wget command every day( daily) , do i need to set the worpress cron fuction as wp_schedule_event( time(), 'daily', 'my_task_hook' )??

    Regards

  2. santosh.sahoo
    Member
    Posted 3 years ago #

    bump

Topic Closed

This topic has been closed to new replies.

About this Topic