First: -perm -g-s is always true. g-s means “s bit not set”, but for the -perm search you need something set and not “not set”. So effectively the find command finds all directories, which in the end gets the job done anyway, even though with a huge overhead, in particular the directories don’t need to be changed again.
Correct would be -perm -g+s to find all directories, which have the group sticky bit set. As we want only those directories which have it missing, the condition must be negated. Thus the correct find command would be:
Second: the content directory contains a lot of directories and if all of them are missing the sticky bit it would make a chmod call for every directory which can take a looooong time.
It is also optimized to use xargs style invocation by using + (which AFAIK is a GNU extension to find, but very useful).
The user reported a 3 minutes vs 3 seconds runtime difference.
Refs #32491 - Optimize pulp find
Taken from the community1. Copy pasting:
It is also optimized to use xargs style invocation by using + (which
AFAIK is a GNU extension to find, but very useful).
The user reported a 3 minutes vs 3 seconds runtime difference.
[1] https://community.theforeman.org/t/contentmigration-katello-3-18-migration-steps-documentation-hicups/23259