Is it possible to run a php function within EE Cron tags? I can make it work, but it seems to ignore the cron tag restriction and run every time page is loaded. I have this setup in my template with PHP Output. I am using a windows IIS 7 server. Can I run this within EE Cron? The get URL is just a sample.
{exp:cron minute="1" hour="1" day="7,14,21,28" month"*"}
<?php>
$handle = fopen("http://domain.com/index.php?ACT=24&export;", "rb"};
fclose($handle);
<?php>
{/exp:cron} Does anyone know how I can do this? I don’t need the page to load in browser, I just need to ping it so the script will run. I just want it to fire one time on day 7, 14, 21, 28. I am trying to hit a page to run a data export function. Is there a better way to do this? I can’t run cron on server so I want to use EE Cron. I know there are other add ons for this, but I want to first try EE cron.
Thanks in advance
Bryan
Unfortunately this host does not allow scheduled tasks to be setup. It is windows hosting. Any way to make this work with EE Cron or another add-on? The EE Cron would work well if PHP would not parse on every load. It is almost like the EE Cron is parses after the PHP. Anyway other way to ping a page? Maybe AJAX?
Unfortunately this host does not allow scheduled tasks to be setup.
Ah, okay. Bummer.
The EE Cron would work well if PHP would not parse on every load. It is almost like the EE Cron is parses after the PHP.
I believe this is a parse order issue. One potential solution might be to move your PHP into a custom EE plugin. I think this would cause your plugin’s exp tag to get parsed after the cron tag is parsed.
Thanks Erik. I have never written a plugin. Is it easy to do? Any samples you may know of I can reference?
You could read the plugin tutorial in the EE docs: http://ellislab.com/expressionengine/user-guide/development/plugins.html Alternatively, I have a tutorial on Nettuts+ based on EE1 plugins. It’s very similar with a few tiny changes: http://net.tutsplus.com/tutorials/cmss/building-your-first-expressionengine-plugin/ Lastly, you could kickstart the code by using a tool built by a few members of the EE dev team: http://pkg.io
What if I placed the PHP code in an embed or snippet, then place within the EE Cron tags?
A snippet wouldn’t change anything, and I don’t think the embed would either. I suppose it’s worth a try though 😊
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.