How to set permissions to the newly generated files in the directory
I'm writing a shell script for MySQL database incremental backup using binary logs. The binary logs are collected in /usr/local/mysql/data/ directory. I have set all permissions to this directory data (chmod -R 777). When I did this, all files in the directory data were granted read,write and execute permissions.
But, when I flush logs, new logs get generated in data directory for which this permissions are not applied. Is there a way where I can apply the same permissions to this files as well. How can I do this? |
First thing is, you should not give 777 permission recursively to any directory, as it means that everyone who can access your system, will be able to access, modify, and alter the log files. So change it to:
Code:
~$ chmod -R 775 /usr/local/mysql/data Third, in your present case, I'd suggest you to apply SGID on the parant directory i.e. on /usr/local/mysql/data, and anyone whom you wish to allow to read content inside it, add to the main group of this directory. Code:
~$ ls -ld /usr/local/mysql/data # Checking owner and group of /usr/local/mysql/data |
All times are GMT -5. The time now is 10:20 AM. |