0

I am developing component for Joomla and I do not know how to make cron. I can not use linux commands because it is complicated for users. Thanks.

2

I understand from your question, that want to run a scheduled task on your Joomla component, but you don't want to use a cron job by the operating system, because the user of your component would have to set it up.

Unfortunately it is no possible to start scheduled tasks from within Joomla, because Joomla is not running all the time. The server just executes the script, once a user issues a request with a browser.

All you can do within Joomla is to attach the execution of some code to a request by a user (a Joomla plugin might be suitable) and remember that by storing the info in the file system or the database, to prevent executing it on every request by a user. In this case you have no influence on the time of the execution though. This might be a problem if you need the task to be executed hourly, because you might not have requests by night. It might also be a problem on low traffic sites.

But I think you can expect the user of your component to be able to set up a cron or the hire someone to do it. There are many other Joomla components like JomSocial that also require cron jobs.

| improve this answer | |
  • Please proofread your answer, I think you can clarify some of your wording. Cron jobs allow timed execution. I'm not sure you should expect ordinary web-users to know how to set up crons easily. – mickmackusa Sep 21 '18 at 9:07
  • 2
    I tried to improve my answer. I am not expecting the web-users to run cron jobs though. As an alternative to a cron job I am suggesting to attach a scheduled task to a request by a web user, maybe via a plugin. – Javatasse Sep 21 '18 at 13:37
  • And what about Joomla update cron? It is also called by user requests? – JaFi Sep 21 '18 at 13:50
  • Do you mean the notification in the backend that tells you that Joomla or some component has available updates? In this case there is no cron. This is executed every time you open the control panel. – Javatasse Sep 21 '18 at 14:01
  • 1
    I just checked and those notifiactions are sent by the Update Notification Plugin, which get's executed on a the onAfterRender event once a user send a request to the server. See docs.joomla.org/Plugin/Events . – Javatasse Sep 21 '18 at 14:42

Not the answer you're looking for? Browse other questions tagged or ask your own question.