3

I have a plugin which doesn't actually integrate with the website. It's purpose is to grab a column of the channel entries table and manipulate it every 24 hours. The plugin will only run each time a cookie expires (24 hours).
Is there a way to have this plugin run without affecting the page load. Currently, by calling the plugin in the template, the page doesn't load until the plugin has completely run.

Am I right to think that I would really need to be write a external PHP script and use CRON to run this every 24 hours?

Or is there a way to do it within the EE environment. I was hoping to use the built in codeigniter library that's built into EE.

Thank you.

2 Answers 2

4

You can do this by developing your add-on as a module rather than a plugin since only modules can use EE actions. (See the EE docs for an explanation of the difference between the types of add-on.)

More info on EE actions here.

Essentially, you need to develop a module to perform your desired action, then call the associated ACT URL (e.g. http://example.com/index.php?ACT=123) using a cron job on your server.

4

You can make a module - like Steve advice. Use Yeoman ExpressionEngine Add-On generator to simplify developing process. On server you will need to setup cron with wget:

execute cronjob every day at 3am
00 03 * * * wget http://example.com/index.php?ACT=XX&task_id=1 

Or if you want something really quick and simple:

  1. Create a special template with some secret name, like http://example.com/kab47jov825yub976on (secret name need just to prevent accidental request)

  2. Place your plugin tag inside this template

  3. Setup CRON request on one of many available cronjob web services. For some project we use setcronjob.com - for 2y was only 1 time when task was failed

    -or- you can setup same CRON job as for module

    execute cronjob every day at 3am 00 03 * * * wget http://example.com/kab47jov825yub976on/

  4. Enjoy.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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