Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

My LAMP is setup to work as user:www-data and all files and folders are created with that permissions.

I have setup for crontab as user@ubuntu.
So i do crontab -e and use this command:
*/5 * * * * php /var/www/public/voto_m/artisan top >/dev/null 2>&1
Basically that command just creates cache file in specified place (no problems with that).
But that cache file is created with user:user permissions not user:www-data permissions.

How can i make that it will by default create file with user:www-data permissions?
I can't go and chown each time file is recreated.

Thanks.

share|improve this question
add comment

2 Answers

up vote 9 down vote accepted

You can write your entry into the system crontab /etc/crontab, which takes an additional argument specifying the user to run as (usually root, but can be www-data).

Your line would become:

*/5 * * * * www-data php /var/www/public/voto_m/artisan top >/dev/null 2>&1

Or you can edit the crontab of user www-data with su:

sudo su -c "crontab -e" www-data
share|improve this answer
add comment

You can also run crontab with the -u argument to edit a crontab for a specific user:

sudo crontab -u www-data -e
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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