1

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.

1 Answer 1

1

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/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.