Monday, May 6, 2024
 Popular · Latest · Hot · Upcoming
53
rated 0 times [  53] [ 0]  / answers: 1 / hits: 97701  / 3 Years ago, sun, june 20, 2021, 5:47:39

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.


More From » cron

 Answers
5

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 -s /bin/bash

[#35533] Tuesday, June 22, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kroapathe

Total Points: 445
Total Questions: 117
Total Answers: 99

Location: Botswana
Member since Sun, Sep 19, 2021
3 Years ago
;