Linux – How to set the file permissions permanently for a directory in Linux

linux

I have a folder in the home directory of my server named stock, as /home/stock. In this folder an ftp dump of data is being done by a third party application. The files added to these folders have a permission 644 and ownership as stock.users.

I also have a cron script which needs to access those files, uncompress it and then take further actions. My cron will run as web.users.

The problem is that my script is unable to access the files because of its permission set as 644. Is there any way to permanently set the folder's permission to 664. Executing the command chmod 664 on that folder, just changes the contents of the folder at that point of time but the files dumped in the future date still has permissions as 644.

Its also not feasible to change the permissions of the folder manually and setting a cron job to do the work doesn't seems a good option either.

Can anyone help ?

Thanks in advance.

Best Answer

It sounds from your description that the cron job just needs to read the files, which it should be able to do. Is the issue that you're trying to uncompress the files in place? Can you uncompress them to a temporary folder instead?

In order to modify the permissions of new files uploaded by FTP, you would need to change the umask of the FTP daemon process to 002. How to do that depends on the FTP server and Linux distribution.