Cron jobs

Τελευταία ενημέρωση από Elxis Team

Χρονικός προγραμματισμός δημοσίευσης και αποδημοσίευσης άρθρων και module με cron jobs.

Since Elxis 4.2 Elxis has a cron jobs system to run scheduled tasks. In Elxis 4.2 this system was limited and supported only the publish of an article on a specific day. No time was supported. Cron jobs in Elxis 4.2 ran once per day. Since version 4.3 Elxis has an advanced cron jobs system allowing you to schedule the publish or the un-publish of articles and modules and even to set up your own custom automated tasks. The interval time between cron jobs run decreased from 24 hours to 10 minutes.

What you can do with cron jobs

You can set an article to be published, or un-published, automatically on a specific datetime. You can set a module to be published, or un-published, automatically on a specific datetime. You can write your own, custom, php code to be executed periodically every 10 minutes.

How do I enable cron jobs?

Cron jobs are by default disabled and you should keep it like that except if you want to schedule the publish/unpublish of modules or articles. You can enable Cron jobs in Elxis general configuration page. There are 2 enablement options for the cron jobs, Elxis and External. The first option uses site visitors to trigger the system. This option is not too accurate but it is perfect for the majority of sites and tasks. It has a 10 minutes time interval and works good on live sites with guests and robots visiting the web site. This option has also the advantage that it does not rely on external software. The second option allows you to trigger cron jobs by an external source like your server's crontab. After clicking Apply a special URL will be displayed below to use it at your server to set up cron jobs.

http://www.example.com/?cronkey=XXXXXX

 

Cron jobs - Elxis configuration
Cron jobs setting in Elxis 4.3+ configuration page.

 

Force run cron jobs

In Elxis configuration, in articles list and in modules list pages there are links or buttons to force run cron jobs immediately.

Cron jobs - articles list
Scheduled items and button to force run cron jobs.

When cron jobs last ran?

In Elxis configuration, in article edit and module edit pages you can see when cron jobs last ran in a human friendly format.

Custom scheduled tasks

Create a folder in Elxis repository named cronjobs and place there any PHP file you want to add in Elxis cron tab system. These files will be triggered by Elxis every 10 minutes. As these files get included by Elxis core you can use all the Elxis libraries, the database connection and everything else as you would have in an Elxis extension. You can for example create a script to take automatically database backups once per day, or send emails to users every Monday, or what ever you like.

Important notes

  • Elxis cron jobs ran once every 10 minutes. If last ran was on 08:21:13 the next ran will be at 08:31:13. If you set an article to be published at 08:25:00 it will be published at when cron jobs will ran, meaning at 08:31:13. So from the set time you have a maximum 10 minutes delay.
  • Even if it is time Elxis driven cron jobs to run, they will not run if the site has no visitors to trigger them! There is also a 10% probability to run. This is in order to reduce the load to the CMS. So, the more visitors your site has, the more accurate Elxis cron jobs will be.
  • Elxis repository must be writeable for cron jobs to run.
  • If you need absolutely accurate cron jobs use the External option.
Έχει διαβαστεί 5392 φορές
Προσωρινή μνήμη
Επόμενο άρθρο
Προσωρινή μνήμη

Μπορείτε να αντιγράψετε, διανείμετε και παρουσιάσετε τα άρθρα αυτού του ιστότοπου για μη εμπορικούς σκοπούς.
Creative Commons 3.0