Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Debug Oil Task Cronjob in Shared Hosting
  • Hi I have a problem when I want to debug my oil task using cronjob in shared hosting

    I am place my crontask like this

    * * * * * FUEL_ENV=DEVELOPMENT php /path/into/myfuelphp/oil refine languages:delete_permanent

    then I am check in my database, it's not delete or no thappening with my cronjob

    actually this is work in my local machine.

    and I don't know how to trace or debug oil for access that task

    any suggestion ?

  • Shouldn't the environment be lower case?

    But that shouldn't matter in this case, "development" is the default environment, so this should work fine.

    To debug it, make sure you're log level is set high enough, so you don't miss warnings and errors. You can use the logger() function in your code to write log entries, so you can later check the logs to see how it went.

    All my tasks contain at least a 'start' and a 'stop' log entry, and I also log things like "xxx records processed" so I have an idea of what the task has done.
  • Thanks for fast response,

    actually I do it like your suggestion 

    my config.php 

    'log_threshold'    => array(Fuel::L_WARNING,Fuel::L_ERROR,Fuel::L_DEBUG),
    'log_path'         => APPPATH.'logs/',

    and then I am place 
     \Log::debug('info', 'start deleting language ...');
    in side method deleting language of my task.

    but that not show anything in my log. it's make me confuse.



  • Have you checked your cron logs to see if it actually starts?

    It is very likely that you don't have an environment in a cron call, which means no search paths, which means 'php' can not be found. I need to prefix it here with the full path to make it work.

    use 'which php' to find the full path (probably something like /usr/bin/php).
  • that is another problem I cannot see logs of cronjob.

    I think PHP is found , because I am testing with another script that create line every one minute.
    and that is work.

    FYI my hosting is shared hosting, how I can do run  'which php'  ? 
  • If you don't have a commandline, that will not be possible.
    I have never used shared hosting, so I don't know.

    Can you run a cron job that redirects it's output?  Maybe you can do

    * * * * * FUEL_ENV=DEVELOPMENT php /path/into/myfuelphp/oil refine languages:delete_permanent >> /some/log/file/location.txt 2>&1

    and have your task echo information out?

Howdy, Stranger!

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

In this Discussion