I am trying to change group and owner (from root to www-data) for a directory.
So I have set a cron on root which looks like this:
0,5 * * * * sudo /bin/chown -R www-data /var/www/pdf/ && sudo /bin/chgrp -R www-data /var/www/pdf/
But unfortunately it's not working. Can anyone please help me?
0,5 * * * * sudo /bin/chown -R www-data /var/www/pdf/ && sudo /bin/chgrp -R www-data /var/www/pdf/
First off, the chgrp
is redundant, you can manage the same with the chown
command itself.
So instead of doing sudo /bin/chown -R www-data /var/www/pdf/ && sudo /bin/chgrp -R www-data /var/www/pdf/
, you can do sudo /bin/chown -R www-data:www-data /var/www/pdf
Now, instead of adding cron to a user's crontab
with sudo
/ to systemwide cron using /etc/cron.d
, add it to the root user's crontab using
sudo crontab -e
1,5 * * * * /bin/chown -R www-data:www-data /var/www/pdf/