views:

305

answers:

3

I'm investigating the best place to set my error logging options, and it seems the most reliable place would be in .htaccess in the script subdirectory. But this particular script is run via cron, and therefore via command line.

Do php_value settings made in .htaccess affect scripts that are not run through the web server?

+2  A: 

No. .htaccess files are only read from the PHP httpd module.

Sean Bright
+2  A: 

.htaccess is used only by Apache. So the answer is NO.

Flavius Stef
+1  A: 

Are you referring to php's error logging settings? Or some custom error logging configuration specific to your cron job?

Either way, you have a few options.

Option 1. Edit your php command in your cron job to include the arguments you want to pass to the script and retrieve them with $argv & $argc. See http://us2.php.net/manual/en/features.commandline.php#86616

Option 2. If you are changing php's error logging options -only- for scripts ran from the cli, you can make those changes in your php-cli.ini (or whatever it might be named on your system)

Option 3. If you don't want to alter php-cli.ini file, you can copy your php-cli.ini somewhere else, make the necessary changes and then alter your php command in your cron job to use the -c /path/to/new/php-cli.ini.

Option 4. Set environment variable(s) on your server and retrieve with $_SERVER['ENV_VAR_NAME_HERE']

I'd be tempted to go with Option 1, unless there are multiple scripts using the same arguments.

Good luck.

simplemotives