0

One of my customers have PHP script which loads cvs file. When he execute this script via WWW it works properly - logs of loaded data are stored in /var/php/CLIENT/loaded.log. But when i try to execute the same script by the same user which Apache executes it and with the same config (php.ini) i recive no data in loaded.log. The same situation if i do this by Cron. Syslog says that Cron recive any errors.

Have you got any clues where i should search?

  • enable logging and you'll see your error, php and php-cli are different – alexus Sep 1 '15 at 13:12
  • script is executed as: su - USER -c "php5.3 /path/to/script/" it used THE SAME user as Apache uses to run this script with the same configuration. I don't know where else i should set logging. – Mateusz Pacek Sep 1 '15 at 13:14
1

When PHP scripts work when run via Apache but not via cron, some common issues can be that the script uses variables only available during a web request such as $_SERVER variables (e.g. $_SERVER['DOCUMENT_ROOT'] or others) or $_GET variables, or it could be a different PHP is used for web requests vs. command line.

Try running the script yourself in shell using the su command you listed but after php5.3, add -d display_errors=on and see if you get any error output.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.