cron - PHP error_log from CLI -


i'm calling php script using cron.

the script use lot error_log function :

error_log('my error'); 

seems it's not working cli.

i can make work using more arguments :

error_log('my error', 3, '/fullpath/to/my/log'); 

but avoid modifying (my script include lot of other scripts).

as far understand, php using different php.ini when called command line.

is there way force use normal php.ini ?

i need cron execute script in exact same environment web.

are there problems should aware of ? others differences break code ?

edit :

i found way tell php php.ini file use (-c):

/path/to/php5 -c /path/to/php.ini /path/to/script.php 

but it's not working. in script shell_exec('php --ini') still showing cli/php.ini...

if need cron execute script in exact same environment web, call the web:

  • setup virtual host (local only, e.g. on port 4242, locked iptables)
  • run cron curl http://localhost:4242/script.php

it run script webserver user, using environment variables, configs, , logs.

to solve exact problem logging, redirect stderr file:

/path/to/php5  /path/to/script.php 2> /fullpath/to/my/log 

the lst part: shell_exec('php --ini') shows default cli/php.ini because start new process default config. show custom config either specify in command line

shell_exec('php --ini -c /path/to/php.ini') 

or show info current process:

phpinfo(info_general) 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -