Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

We have an FTP where customers can drop their files. We want to run a script that sweeps the files out of the folders every 15 minutes.

The current permission and folder structure looks like this:

drwxr-xr-x  3 root ftpusers 4.0K Apr 12 20:45 client1
|-- drwxr-xr-x  3 client1 ftpusers 4.0K Apr 12 20:45 incoming
|-- drwxr-xr-x  3 client1 ftpusers 4.0K Apr 12 20:45 processed
drwxr-xr-x  3 root ftpusers 4.0K Apr 12 09:58 client2
|-- drwxr-xr-x  3 client2 ftpusers 4.0K Apr 12 20:45 incoming
|-- drwxr-xr-x  3 client2 ftpusers 4.0K Apr 12 20:45 processed
drwxr-xr-x  3 root ftpusers 4.0K Apr 12 07:06 client3
|-- drwxr-xr-x  3 client3 ftpusers 4.0K Apr 12 20:45 incoming
|-- drwxr-xr-x  3 client3 ftpusers 4.0K Apr 12 20:45 processed

My first thought was to create a user that has no password and make it part of the ftpusers group and then give ftpusers write access, but that seems like it would give unnecessary permissions to the client* accounts that wouldn't be secure. Also, vsftp prohibits using chroot jails with folders that have write access to any other user than root.

What is the best practice for setting up a cron / user that can execute a task like this? It's job is going to be finding all files in the incoming folders, pushing them to an API and then moving them to the processed folders. It needs to be able to modify files across the entire set of folders.

share|improve this question
    
Why can't you create account which can sudo into client1 account and then manipulate all the files. Oh also since you cron jobs are not running inside tty in your /etc/sudoers file you will have to comment these 2 options: #Defaults requiretty, #Defaults !visiblepw –  Danila Ladner May 15 '13 at 0:20
    
We want the account to be able to modify all the files for all of the clients. I suppose it could sudo into each account but that seems a little excessive. Is that the best way to handle this? –  Jeremy Baker May 15 '13 at 2:15
    
You could create an account with wheel group membership and sudo into that account. –  Danila Ladner May 15 '13 at 12:09

1 Answer 1

As a root when we use mv command it do not change ownership and permission.

And if you would like to copy the files. use cp -p , her -p will keep the permission and ownership.

These two commands you can use in your script and put the script in root's crontab.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.