Why do only certain Cron intervals run?

I noticed that on my_website/admin/cron page (Elgg3.3.2) only certain Cron intervals run for example fiveminute, fifteenminute, halfhour, and hourly. But daily, weekly, and monthly do not. Why is that?

Explanation or clarification would be greatly appreciated.

  • Make sure the cron account and the webserver account are the same.

    Sounds like something that's causing me a problem. When I try to clear the cache, I get this error:

    ELGG.CRITICAL: Exception at time 1587668791:
    UnexpectedValueException: RecursiveDirectoryIterator::__construct(/var/www/elgg/data/caches/stash/0fea6a13c52b4d47/25368f24b045ca84/38a865804f8fdcb6/57cd99682e939275/470dcd7b646bfcf1/6d7f0e85bd145ac4/dca130d8a1c165eb): 

     Where the access rights to the folder

    dca130d8a1c165eb

    are at the root but not at the webserver. If I disable the Cron, everything works fine.

    Can you help me figure out how to set the permissions to the cron account and webserver same?

    Thanks for help

  • But it logs for other intervals such as fiveminute, halfhour, hourly, etc. EXCEPT daily, weekly, or my custom intervals.

     

  • Can you help me figure out how to set the permissions to the cron account and webserver same?

    Run the cron jobs from the crontab of the webserver account, that's easiest. Otherwise sudo -u <webserver account> elgg-cli ....

  • @ronnim Read this also.

    @seri_ng Do you have any of the things I advised you to do?

  • @RvR No I do not have 'elgg_log( )' in my function BUT that still does not explain other fiveminute cron hook though. When I tested using fiveminute interval rather than daily interval, without 'elgg_log( )' in my function it logged the cron details.

  • Let's start from beggining.

    Configs:

    My webserver name is www-data

    My Elgg is installed in /var/www/elgg

    My PHP is executed from /usr/bin/php

    Cronjob installation:

    Run crontab as webserver user:

    crontab -u www-data -e

    Set only 1 cronjob:

    * * * * * /usr/bin/php /var/www/elgg/vendor/bin/elgg-cli cron -q

    Save crontab.

    Check it:

    crontab -u www-data -l

    Make cron trigger in your plugin:

    start.php / Bootstrap class:

    elgg_register_plugin_hook_handler('cron', 'daily', 'my_cronjob_function');
    
    function my_cronjob_function(\Elgg\Hook $hook) {
        echo 'Starting cronjob' . PHP_EOL;
        elgg_log('Starting cronjob', 'NOTICE');
    
        // ignore access
        elgg_call(ELGG_IGNORE_ACCESS, function() {
             //do it something here
        });
    
        echo 'Done with cronjob' . PHP_EOL;
        elgg_log('Done with cronjob', 'NOTICE');
    }
    Notes:
    • Use 'ignore access' always
    • Use the mentioned logs samples before/after cronjob always.
    • SSL on the site is required (it's reason why you've issues on the localhost).
     
    If nothing works after this small tutorial then you have troubles on the server, your code and/or read+write rights permissions.
     
  • Thanks for step-by-step instructions RvR! 

Beginning Developers

Beginning Developers

This space is for newcomers, who wish to build a new plugin or to customize an existing one to their liking