Codeigniter CLI does not log to database |
Hey Guys,
I tried asking this question on StackOverflow, but I think people do not have the correct knowledge to help me out. At least the one answer I got was not what I was looking for... So here goes. I have the following function which updates the status of my vacancies (based on dates) and logs the amount of vacancies that got a change, it looks like this: PHP Code: //Function used to check the statusses of every vacancy and update it accordingly This is put in a cronjob to be executed every 30minutes, like so: Code: */30 * * * * /usr/bin/php /var/www/index.php cli/cron checkVacanciesStatusses >/dev/null 2>&1 The code for the createCronLog in my logmanager looks like this: PHP Code: class LogManager { The thing which I cannot wrap my head around is that the vacancy updates (so the model calls) work perfectly. But the logging does not work. When I comment the if clause which checks if it is a cli_request, and I manually browse to the function, the vacancies gets updated AND the logging works! What is happening? It is not giving any errors or whatsoever, it just works when executed manually.
Of course there are no errors, because you are suppressing them:
Code: >/dev/null 2>&1 Remove that and try again. (01-18-2018, 01:14 PM)skunkbad Wrote: Of course there are no errors, because you are suppressing them: Hello Skunkbad! I tried removing that, there are no errors, the only thing it returns is warnings about the time usage, that's all. If i execute thiswithout the IF cli check, the logging does happen. So I know the code is working as intended.
(01-19-2018, 05:19 AM)creawbe Wrote: Hey Dave! I didn't understand that it was happening that way. But yes, I would think so. What happens if you comment the cli check and have cron execute? Same behavior?
i have a similar issue in one of my crons job, so remove the if statement.
Another method is to call the controller method via curl since you want to secure the execution of that page. (01-19-2018, 07:32 AM)dave friend Wrote:(01-19-2018, 05:19 AM)creawbe Wrote: Hey Dave! Yep, exact same behavior. Statusses get updated but the logging does not occur... (01-18-2018, 07:45 AM)creawbe Wrote: The syntax after index.php should be the same as if you enter it in a URL. I don't know what 'cli/cron' is in there, maybe dir/controller, but the fact that the checkVacanciesStatusses is separated from them doesn't look right. (01-19-2018, 02:35 AM)creawbe Wrote:(01-18-2018, 01:14 PM)skunkbad Wrote: Of course there are no errors, because you are suppressing them: This can't be true if only the logging doesn't work - either the entire thing doesn't work under CLI, or you have more errors. You've used $_SERVER['REQUEST_URI'] in there, and that variable doesn't exist under a CLI environment, so there must be a warning about that. |
Welcome Guest, Not a member yet? Register Sign In |