Closed lonevvolf closed 4 months ago
chown supports setting the owner and group in a single command
Correct.
Could the two calls be combined into one to help improve the speed?
This was the original behaviour of the container but unfortunately it was too slow. chown
ing all the files on a large library takes a looooong time. To optimise this, I use find
to check for all the files which do not have correct owner and then only chown
those files. Then I use find
to get all the files which do not have the correct group, and chgrp
those files.
Unfortunately, combining the two find
parameters into a single command doesn't produce the required results. find
parameters are taken as and
rather than or
so:
find . ! -user "${user_id}" ! -group "${group_id}" -exec chown "${user_id}:${group_id}" {} +
only finds files that have both user and group set incorrectly. It will not find files for which only one of these is wrong.
If you know of a way to make find
show files that have one of the two properties set incorrectly, then it may be possible to improve the performance, but as it stands, moving back to a single chown
command will only decrease performance.
I've seen that the calls to chown/chgrp take quite some time if you have lots of files. chown supports setting the owner and group in a single command: https://linux.die.net/man/1/chown
ie. chown tito:editors file.txt
Could the two calls be combined into one to help improve the speed?