I want to run a crontab command every 5 mins that executes a py script. The py script inturn generates a log file with midnight rotation within /var/www/logs/.The logs dir has 777 permission.
The log file has midnight rotation and when new file is created,it creates as root owner.How to ensure the ownership stays as www-data as some other scripts also write to the same file and having root ownership causes permission issue for other scripts.
One way is to put the command in,
crontab -u www-data -e
This works fine, but i want to maintain all my cron commands under root user.
I tried doing the same with sudo, but it creates with root as owner which not what i want.
/etc/crontab
can be used to execute scripts with a user as the one starting it. – Rinzwind Jan 24 '18 at 11:18www-data
as the file owner check/etc/logrotate.conf
and add a block of setting regarding your log file. – M. Dm. Jan 24 '18 at 15:03