0

I need a cron job in one of my older web site (CakePHP 1.3). I made the following steps:

  1. created shell in /somepath/public_html/app/vendors/shells/valute.php

    class ValuteShell extends Shell {
        var $uses = array('Valute');
        function main() {
            $this->Valute->cacheGetKonverterData();
        }
    }
    
  2. created BASH script and save this to my vendors folder as cakeshell (/somepath/public_html/app/vendors/cakeshell)

    #!/bin/bash
    TERM=dumb
    export TERM
    cmd="cake"
    while [ $# -ne 0 ]; do
        if [ "$1" = "-cli" ] || [ "$1" = "-console" ]; then
            PATH=$PATH:$2
            shift
        else
            cmd="${cmd} $1"
        fi
        shift
    done
    $cmd
    
  3. changed the permissions on the this file to 777.

  4. called cronjob like this:

    0  0   *   *   *   /somepath/public_html/app/vendors/cakeshell valute -cli /usr/bin -console /somepath/public_html/cake/console -app /somepath/public_html/app
    

Unfortunately cronjob does not work. Why? When I call: http://www.somedomain.net/valutes/save_valute everything works fine.

<?php
class ValutesController extends AppController {
    var $name = 'Valutes';
    var $uses = array('Valute'); 

    function save_valutes()
    {
        $this->layout = null; // turn off the layout    
        $this->Valute->cacheGetKonverterData();
    }   
}
?>
cornelb
  • 6,046
  • 3
  • 19
  • 30
user2580714
  • 21
  • 1
  • 3
  • possible duplicate of [Cron Dispatcher CakePHP 2.0](http://stackoverflow.com/a/23636079/761202) (while this question uses a custom bash script - the right solution is to just call Console/cake ). – AD7six May 13 '14 at 16:02

1 Answers1

0

cakeshell: cmd should have the PATH of the Cake core's cake file

cmd="/somepath/public_html/lib/Cake/Console/cake"

crontab:

0 0 * * * /somepath/public_html/app/vendors/cakeshell valute -app /somepath/public_html/app >> var/log/crontab
cornelb
  • 6,046
  • 3
  • 19
  • 30
  • thank you for your reply, but unfortunately that's not working – user2580714 Feb 17 '14 at 10:07
  • I did not notice the error. I solved the problem in another way: curl -sfo /dev/null www.somedomain.com/controller/action/secret_code. This is the sort of improvisation, but it works. – user2580714 Feb 17 '14 at 13:16