Jessica Belao
Jessica Belao

Reputation: 67

Error_log doesn't work when PHP script is running via /user/bin/php

Well I have a cron that runs a bash file:

#!/bin/bash

for n in {1..10}; do
   /usr/bin/php /var/www/html/teste_sh.php v=$n &
done

But in this script teste_sh.php, If I do an error_log, it doesn't work.

Error_log of this folder is empty, but if I run http://localhost/teste_sh.php, error_log works fine!

Is there a way to make error_log work in this case?

Thanks.

Upvotes: 1

Views: 170

Answers (1)

ficuscr
ficuscr

Reputation: 7054

Not exactly clear on where your error log is, but, It's a permission issue. The CRON assumedly is a crontab on your user, not root.

I would place your user in the same group as your web server, often www-data.

Then the web server, and you when executing via CRON, will be in same group. Of course just need to make sure the directory /var/www/html is chowned to that group.

Add your user to web group:

sudo usermod -a -G www-data myusername

And then chown the directory

sudo chown -R myusername:www-data /var/www/html

Might be worth taking a look for an answer on https://serverfault.com/

Upvotes: 1

Related Questions