Cron Jobs

I have been researching cron jobs for weeks now in trying to set up cron jobs for an elgg site.  I have read all the documentation and still don't understand how all of this works.  My hosting company is telling me they can not find a file which should be called cron.php for the cron job. So I'm trying to understand how all of this works.  

The documentation for elgg states that the most common examples of cron jobs in elgg include:  sending out queued notifications, rotating the system log in the database, collecting garbage in the database. So if I go to usr/bin/php/home/username/public_html/mysite.com/mod/garbagecollector/views/default/plug_ins/garbagecollector/settings.php.  The settings.php is a file that looks like it is set up for garbage collecting as defined by elggs documentation.  So, is this the string I would put into my Cpanel?  where would I put minute. 5minute or daily?

What if I wanted to set up a welcome letter to everyone that joins?  Would I then create and put a script in a cron.php file?  If so, what would the script say?   I know the issue of Cron jobs has been covered in this forum many times but I can't find the answers I'm looking for.  Any help would be appreciated.

  • There is no server side script to run cron. You just need to hit the public URL of the cron page, hence cron instructions mention wget and curl. You can be your own cron job, and go visit http://mysite.com/cron/minute every minute.

    If you want a server side script, you can create your own cron.php that will:

    a) load vendors

    b) start the Elgg app

    c) and trigger "cron",$period hook

  • IMO, you don't need cron to send our welcome messages. Listen to "create","user" event, or "register", "user" hook (see uservalidationbyemail for example), and use notify_user() to send the welcome message

  • Okay, thank you for the answer.  I am still researching this and have downloaded wget - 1.19.tar.gz.  Do I put that in my public_html/mysite.com?  I read in another post to put in the command line of Cpanel:  wget https://mysite.com/cron/minute for a cron job every minute but they don't say where the wget comes in.    Is that correct?  Do I even need a cron job at all?    Im sorry for my ignorance on this but I am trying to understand.  Thank you again for all of your help.

  • Cron is part of the Elgg installation, unless you plan to audit the code to determine whether you need it.

    Can you just post a screenshot of your cron config page on imgur or whatever?

  • It's very, very likely that wget is already installed on your server. So, no need to add this package on your own. You can ask the support of your webhoster if wget is available on your server and if it is about the path to the wget executable. If it's not installed, I would suggest to ask the support about adding wget for you or to ask them how to install it. If you have shell access on your server, you can also try a "which get" command to find out if wget is installed and if it is to find out about the path.

    With CPanel you can configure the cronjobs of Elgg easily, if the Cron administration module is available. When setting up a cronjob you can select the interval the cronjob command should be executed and then enter the Elgg-cronjob command (interval-specific). The only thing the command does is to call a certain url of your site with wget. If the Elgg engine notices a visit to such an url, it will execute the Elgg-cronjob registered by Elgg core and plugins.

    For example the "minute" cronjob command would be

    /usr/bin/wget --output-document=/dev/null http://site.url/cron/minute/ >/dev/null 2>&1

    You might need to adjust the path to the wget executable. And you need to adjust your site url to match the url of your site.

    For the other intervals the command is basically the same with only the last url segment different to match the various cron intervals (fiveminute, fifteenmin, halfhour, hourly, daily, weekly, monthly, yearly). For each of these cronjobs you would have to set up the corresponding interval in the CPanel module.

    You should create cronjobs in CPanel at least for the intervals used on your site by Elgg core and plugins. With the Croncheck plugin (https://elgg.org/plugins/1864611) you can check which intervals have cronjobs registered in addition to checking when the cronjobs have run the last time.

    If your haven't managed to set up the cronjobs in CPanel yet, you can use the Crontrigger plugin (https://elgg.org/plugins/2512029) as fallback. This plugin is only necessary if you can't manage to set up the cronjobs on the server as it's relying on at least one user being active on your site (user action triggers the check if a cron interval has been reached).

  • Thank you everybody for your help. I think I have this working now