1
kerkyra
How to create a cron in Xoops
  • 2011/12/1 16:33

  • kerkyra

  • Just can't stay away

  • Posts: 553

  • Since: 2005/2/14


Does anybody know how to create o cron job in xoops? I have made an effort but it only runs through the web browser.

If i set it up to run from the server it gets stuck and i think the problem is protector or something like that.

Any ideas what i should include in the header? Or not include...

2
Mamba
Re: How to create a cron in Xoops
  • 2011/12/1 20:38

  • Mamba

  • Moderator

  • Posts: 11366

  • Since: 2004/4/23


You can take a look at XoopsCare, which I think, provided this kind of feature.

Also, Wishcraft is using cron jobs in his TwitterBomb module, but I don't know if he is creating those jobs, or if they are created manually first and then he is just using them.
Support XOOPS => DONATE
Use 2.5.10 | Docs | Modules | Bugs

3
deka87
Re: How to create a cron in Xoops
  • 2011/12/1 20:55

  • deka87

  • Friend of XOOPS

  • Posts: 1125

  • Since: 2007/10/5


cron is also run in the subscription module by thirdeye software. you can take a look on it too
Mind anchors

4
redheadedrod
Re: How to create a cron in Xoops

To create a Cron with Xoops the method is to put PHP code into a block that is invisible but include it in every page.

Not sure exactly how to do it but that is the method with xoopcare and some others. That PHP code then calls your Cron events.

You could theoretically do that by including code in your theme I suppose as well and might be easier to do. Something that is done all the time.

Problem is with the code above it will be a hit on systems that have a lot of users because it will be run every time someone updates a page. Even cached it could produce some big hits on a big site.

Thinking there might be a better way but not sure of the code to do it...
If you place code in your theme that looked at a flag to see if it needed to be updated then called an external script and reset that flag then run the cron it could be done that way. If you do it with JavaScript and an Ajax call you could do it in the back ground and the user never would see a delay.


Attending College working towards Bachelors in Software Engineering and Network Security.

5
kerkyra
Re: How to create a cron in Xoops
  • 2011/12/2 11:25

  • kerkyra

  • Just can't stay away

  • Posts: 553

  • Since: 2005/2/14


thanks for the replies mates! I'll give it a try and see what i can do.
if i find anything usefull i'll post it here :)
www.guidemap.gr - Beta is out...

6
anderssk
Re: How to create a cron in Xoops
  • 2011/12/2 20:36

  • anderssk

  • Quite a regular

  • Posts: 335

  • Since: 2006/3/21


I do have a cronjob, but thats inside Cpanel (webhost admin panel)
It create one file of all mails, distribution lists, domain files (and subdomain) and of course all databases.
The file is sendt trough SFTP to my private NAS server and from the NAS I can pick files and databases to my localhost machine for testing.

If you use Cpanel I can help set this up.

7
kerkyra
Re: How to create a cron in Xoops
  • 2011/12/3 13:05

  • kerkyra

  • Just can't stay away

  • Posts: 553

  • Since: 2005/2/14


unfortunately i'm on plesk, i did something tha partially worked. I could use pure php to do this, but i want to include the xoops core so i can use some of its functionality.

It seems that there is something wrong with protector and/or the debugging information and for some reason i cant turn them off while running the cron... I'm not sure about this, i'm looking into it and trying things (trial and error).

If i figure it out i will post my observations here for the rest to have something to start with. :)
www.guidemap.gr - Beta is out...

8
kerkyra
Re: How to create a cron in Xoops
  • 2011/12/6 11:09

  • kerkyra

  • Just can't stay away

  • Posts: 553

  • Since: 2005/2/14


i managed to figure this out, so here are my observations.

if you would like to run a cron job and use existing xoops functions, constants etc you would have to

1. include the mainfile.php
Quote:
include_once("root_path/httpdocs/mainfile.php");

where root_path is the absolute root path to your site

2. include the xoopslogger class and disable it (in case it is on)
Quote:

include_once XOOPS_ROOT_PATH.'/class/logger/xoopslogger.php';
$xoopsLogger =& XoopsLogger::getInstance();
$xoopsLogger->activated = false;
error_reporting(0);

as you can see i disabled error reporting as well, this is not mandatory (i think) but I did it anyway since I finished my debugging.

3. set the cron in your cpanel/plesk or whatever

Thats actually it. Now you can use any core functionality like xoops_load(), $xoopsDB etc, or load any languages on the fly as we would do in a module function.

I implemented this for a newsletter module i'm writing and its working fine so far. I hope it helps someone.

Maybe when i'm done with the module i will share it with the rest, although it is designed to serve my websites needs, and its based on the same logic as my Xoops Global RSS Hack/Solution.

I just want to share the logic.

Both global RSS and Newsletter functionality is missing from xoops but that doesn't mean we cant have it :) (without touching core files)

Login

Who's Online

214 user(s) are online (155 user(s) are browsing Support Forums)


Members: 0


Guests: 214


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Mar 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits