Trouble with cron plugin hook

Hi. I'm trying to get a script to run every hour, but it's not being triggered. Here's all the relevant code in my start.php. Do I need anything else in here to get my finishChallenges function to work?


elgg_register_event_handler('init', 'system', 'profile_tweak_init');

function profile_tweak_init() {

//miscallaneous code


register_plugin_hook('cron', 'hourly', 'finishChallenges');

}

function finishChallenges($hook, $entity_type, $returnvalue, $params) {

//miscellaneous code

}

 

  • Hi Ismayil. I hadn't, but I did so after reading your post.

    I tried doing crontab -e with this file:

    # Location of GET
     GET='/usr/bin/GET'
     
     # Location of your site (don't forget the trailing slash!)
     ELGG='http://www.example.com/'
     
     # The crontab
     @reboot $GET ${ELGG}cron/reboot/
     @minute $GET ${ELGG}cron/minute/
     @fiveminute $GET ${ELGG}cron/fiveminute/
     @hourly $GET ${ELGG}cron/hourly/
     @daily $GET ${ELGG}cron/daily/
     @weekly $GET ${ELGG}cron/weekly/
     @monthly $GET ${ELGG}cron/monthly/
     @yearly $GET ${ELGG}cron/yearly/

    But that didn't work. I got "bad time specifier" messages. So I then changed the file to this:

    # Location of GET
    GET='/usr/bin/GET'

    # Location of your site (don't forget the trailing slash!)
    ELGG='http://www.example.com/'

    # The crontab
    @reboot $GET ${ELGG}cron/reboot/
    * * * * * $GET ${ELGG}cron/minute/
    */5 * * * * $GET ${ELGG}cron/fiveminute/
    0 * * * * $GET ${ELGG}cron/hourly/
    0 0 * * * $GET ${ELGG}cron/daily/
    0 0 * * Sat $GET ${ELGG}cron/weekly/
    0 0 1 * * $GET ${ELGG}cron/monthly/
    0 0 1 1 * $GET ${ELGG}cron/yearly/

    But it's still not working.

  • I assume you have changed the location of your site. Do a google search, there are plenty of resources out there. If 'get' doesn't work, try wget or curl. I tend to use curl

  • you need to do that in Cpanel of your hosting account.. just need to enter

    curl http://your_site.com/cron/daily like that

    its as simple as that

  • I have the same problem. Is really necesary to configure crontab on my server?. For example Garbage collector work with plugin hook and it isn't necessary to use crontab on server. No? I try a lot of options whitout results.

  • Some servers don't support the @... shortcut, so just remove the @reboot and any remaining @ and this should work as expected :

    # Location of GET
    GET='/usr/bin/GET'

    # Location of your site (don't forget the trailing slash!)
    ELGG='http://www.example.com/'

    # The crontab
    * * * * * $GET ${ELGG}cron/minute/
    */5 * * * * $GET ${ELGG}cron/fiveminute/
    0 * * * * $GET ${ELGG}cron/hourly/
    0 0 * * * $GET ${ELGG}cron/daily/
    0 0 * * Sat $GET ${ELGG}cron/weekly/
    0 0 1 * * $GET ${ELGG}cron/monthly/
    0 0 1 1 * $GET ${ELGG}cron/yearly/