开发者

Joomla Is it possible to execute a plugin automatically at regular intervals

开发者 https://www.devze.com 2023-02-03 11:18 出处:网络
Hi I made a Joomla Plug-in which gets some external content and saves it in an HTML fil开发者_开发技巧e.Wanted to know is it possible to automatically execute this plug-in at regular intervals.

Hi I made a Joomla Plug-in which gets some external content and saves it in an HTML fil开发者_开发技巧e. Wanted to know is it possible to automatically execute this plug-in at regular intervals.

If yes what will be the process?

Or the other way is it possible to place this script in some file and automatically execute it on a regular interval.

Kindly help.


yes, you'll want to use cron to do a repeated scheduled task such as this. see this primer on cron as an example, here' is my cron file for a script I run every 30 minutes to update Google safesites info...

# m h  dom mon dow   command
30 * * * * /usr/bin/php /OBFUSCATED/PATH/TO/MY/SCRIPT/listupdater.php

to set this up you need SSh access to your server and from the command line you'll type

crontab -e

you may want to read up on how to edit in a vi-style editor...


Joomla is PHP, and PHP does not execute in regular intervals. You will need to trigger it from an outside process. Luckily, all modern operating systems offer you ways to do this. It can be a cron job (for unix-like OS'es) or a Scheduled Task (windows).

What you'll most likely want is to add a commandline PHP script which executes a page (php <name of script>). Joomla depends quite strongly on GET parameters to do its routing... so you might want to consider running this not as a Joomla plugin, but as arbitrary code sitting in a .php file, while still utilizing the Joomla framework. Or write an alternative to Joomla's index.php which fills $_GET with the values needed to route to a page where your plugin can do its thing.


Alternatively, you can create a plugin that loads on every request, which checks (by means of a file, or database field) whether it has run recently and immediately returns if it doesn't have to do anything. Of course this is less accurate: It depends on a steady stream of pageviews. and causes delays for your visitors if they happen to be the one requesting a page that triggers such a maintenance job.

0

精彩评论

暂无评论...
验证码 换一张
取 消