Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Error 500 with Crontab and Tasks
  • Hi there!
    I'm pretty new (and French, sorry!) to FuelPHP but I'm a former CI dev so I'm lost. I'm coming to you because I'm getting into trouble using Tasks with Crontab on my shared hosting. While running my custom Task via SSH, there's no problem. But when setting a Cronjob (via the admin panel of my hosting or directly via SSH), I'm getting this 500 error :
    Error!
    ErrorException [ Error ]: Class 'Fuel\Core\Exception' not found
    COREPATH/classes/cli.php @ line 72

    With this code excerpt (Line 72 is overlined) :
    67     */
    68    public static function _init()
    69    {
    70        if ( ! \Fuel::$is_cli)
    71        {
    72            throw new Exception('Cli class cannot be used outside of the command line.'); // <----
    73        }
    74        for ($i = 1; $i < $_SERVER['argc']; $i++)
    75        {
    76            $arg = explode('=', $_SERVER['argv'][$i]);
    

    My Task is just a test and looks like this :
    <?php
    namespace Fuel\Tasks;
    
    class Test {
     
        public static function run($message = 'Hello!')
        {
            return $message;
        }
    }
    

    I'm using a simple Cronjob like this (every minute, just for testing purpose) :
    * * * * * php /path/to/my/fuelphp/oil refine test
    

    I really don't what's going wrong there... Especially since everything works fine in the shell via SSH. What can be different between running PHP via SSH and via Cron? Can anyone help me with that? Any help will be greatly appreciated! -- Bastien
  • Contrary to popular belief, the "cron" function provided by many control panels isn't a cron at all, it's just a script that schedules and spawns background tasks. As a result of that, the scripts don't run using php-cli, which is required for oil scripts. I remember some fixes related to this a few weeks ago, so you might want to upgrade to 1.2RC1.
  • Thanks for your answer. I had already planned to try the 1.2RC, I'll see if it solves the problem or not. Besides, I've also tried directly the "crontab" command via SSH: the result was unfortunately the same than with the tool provided on my admin panel.
  • Yep, got some news! I just upgraded my app to FuelPHP 1.2RC1 and now I got a nice user-friendly error from Oil:
    The use of oil is not supported when running php-cgi. Oil needs php-cli to function!

    Yes, my shared hosting is running PHP 5.3.10 (cgi-fcgi)...
    I'm contacting the tech support to see if they can switch me to PHP-CLI. Stay tuned =)
  • If 'php' runs 'php-cgi', then with a bit of luck you'll have 'php-cli' available too. Can't you run that?

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion