Click to See Complete Forum and Search --> : using mv with NFS


mrwill
09-08-2003, 02:04 PM
Hello, I am still fairly new to UNIX and I am attempting to set up NFS. This is a This is a team project for class and I want to use mv to move files across NFS. One box is zipping backup files and storing them. My box is mounting their drive and "mv"ing their files to a directory on my box. I want to keep the files for 1 hour and then delete them. However, cp won't work because it restamps the time when I copy their files over so no files ever have 1 hour of time stamped. I want to use mv so that it completly moves their files over and deletes them off of their drive. This seems to be copying the files and giving the error stating that it can't unlink the file but still copies it. Our permissions seem to be correct and everything seems to be in order. But, some research on the net indicates that mv has a problem with NFS. Can anyone help with this matter? I am determined to get this working now, my interest is piqued on this matter. Thank you in advance for any help you may give. Have a good day.

Will

bwkaz
09-08-2003, 07:18 PM
mv isn't having a problem. ;) It looks like you just don't have permission (on the NFS server) to delete the files. Make sure your UID is mapped to a username over there, make sure you're not trying this as root, and make sure the username whose UID is the same as your local UID has permission to write to the directories containing these files that you want to delete.

mv will always copy-then-delete files when it's trying to move them across partitions anyway, though. That might be why you read that mv had issues with NFS (or I might just not know my NFS very well... that's always a possibility). If you were reading about problems with Unix versions of mv, then you should know that GNU mv is much, much better than the mv that comes with most Unix versions. This is one thing that it does better -- some (very few) versions of mv probably won't copy-then-delete, they'll just fail if the source is a different partition from the destination

But if you want the files to be deleted after an hour, then why is it bad that cp is setting the ctime to the current time? Just do a find /path -cmin 60 and delete the results... (the argument to -cmin is in minutes, and -cmin checks the last metadata change time) The files will become one hour old exactly one hour after you copy them over...

mrwill
09-08-2003, 08:01 PM
One computer backes up its directory every10 minutes and the files are datestamped to make unique files. My computer takes those files every 10 minutes (schedules are set with cron). So, when I use cp it copies everything in their backup folder back to my mount point and at that point, time starts again, right? That is the reason I was going to use mv, so that when I took their file, no files would be left in their folder. Am I on the right track? I am fairly sure I can do this in 1 line of script. Any thoughts?

Thank you,
Will

bwkaz
09-09-2003, 07:06 PM
Originally posted by mrwill
One computer backes up its directory every10 minutes and the files are datestamped to make unique files. Why not just use tar? It'd be one heck of a lot simpler...

You'd still need the timestamp, but at least you wouldn't have ten billion files laying around... (unless I misunderstood what you're doing)

That is the reason I was going to use mv, so that when I took their file, no files would be left in their folder. ... Oh. ;) I thought you were using mv to preserve the timestamp on the file (either the ctime or the mtime).

Have you checked which UID your requests are mapping to on the remote machine? Check the permissions for that user on the backup directory itself (the one that you're removing files from).

mrwill
09-10-2003, 09:49 AM
....yeah, the backup computer tar and zips its files to its backupp directory and I come and get the files after I mount their backup to my directory. That is why I was wanting to use mv to make a clean move to my directory and delete the files from theirs. Thanks for the suggestion about the UID. I will check that out this evening. At last try, I will just cp the files and then delete them (forced) after cp. I wanted to do it in one command, but at least I will be able to do what the plan intended. I just wanted to see if I was on the right track. Thanks for your help. It is greatly appreciated.

On an a different note, where can I learn more about getting certified in UNIX or Linux. I am just starting ( I have had 2 semesters) and I love it. I really want to do this for a living. It is is so much fun. Thanks for any suggestions.

Will