cron for Elgg on Windows

Our website (Elgg1.8.5) is running in xampp in a dedicated Windows 2003 server. It seems no cron running for Elgg. How can I check it, and how can I setup cron env. for Elgg Garbage Collector and Log Rotate?

  • I'm not sure about your cron issue - but I was always under the impression that xampp wasn't a production ready environment - all security features are pretty much absent.  I use it for localhost development, but I shudder at the thought of actually hosting a live site on it.

  • How about that:

    1. create a directory named "crontest" in htdocs,

    2. create a file named "crontest.php" in crontest directory. To see if it works you can create a "test cron job"

    <?php
    // Output of Batch file
    echo "Our cronjob works!";

    3. create a "cron.bat" (.bat ending is important):

    @C:\Programme\xampp\php\php.exe -f crontest.php
    @PAUSE

    (You might need to adjust the path to php.exe. The @PAUSE is mainly useful for testing as it keeps the window open. You can also go without it.)

    4. Add "cron.bat" as scheduled task in Windows control panel.

    As for Elgg's cronjobs you could add something like this in crontest.php for the monthly cronjob (and you would then schedule this job as monthly in Windows control panel)

    $url = 'http://yoursite.url/cron/monthly/';
    $cmd = "wget --spider --output-document=/dev/null \"$url\" -O >/dev/null 2>&1";
    exec($cmd);

    I'm not sure about /dev/null being available in xampp as I don't use it myself. Otherwise, it should work without

    $cmd = "wget --spider \"$url\" ";

  • Hi iionly,

    Thanks for your advice. Now I use vbscript+IE instead of wget, and it works fine. 

    1. create a vbs file "C:\cronfiveminute.vbs"

    DIM IE
    SET IE = CREATEOBJECT("INTERNETEXPLORER.APPLICATION")
    IE.VISIBLE=0 '1=display IE window,0=hide IE window
    IE.NAVIGATE("http://websiteurl/cron/fiveminute/")
    WScript.Sleep 5000  'sleep for 5 seconds
    IE.Quit()
    SET IE = NOTHING

    2. add a scheduled task in Windows to run for every five minutes

    wscript //e:vbscript C:\cron_fiveminute.vbs

  • Hi Matt,

    It would be appreciated if you can advise instead of xampp what env. is better for a production web server on Windows 2003.

  • Sorry I don't have any advice for you on that point - I've never used windows for hosting, always linux.  All I know is that xampp itself on their site cautions you not to use it for production hosting.  I'm sure google could turn up better options.

  • Win2K3 itself IS a web server ;-) your host tech support can answer your question better. 

  • Thanks Matt and DhrupDescoop.