Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

moving a file to destination without enough space

Status
Not open for further replies.

yowza

Technical User
Nov 28, 2001
121
US

Does anyone know what happens when you mv a file to a destination that does not have enough space? What happens to the original file? I don't think you get an error but I'm not sure.
Any recommendations on how to do this with another command that would return an error? We want to archive some audit logs to a different filesystem. This is done in a very basic script with no error checking etc. Just mv filea to /new/filea type thing. It would be nice if we could use a command that would tell us if the mv or copy was successful or perhaps if there is enough space to perform the operation.
Any help or tips is greatly appreciated.

Thanks,
yowza
 
With df -k, you call tell how much free space you have in the file system. You can then test if your file size is bigger than the free space is.
Else if you try to move to a full file system, you will get an error returned (check status)
Too bad I.T. is not cash business

Luc Foata
Unix sysadmin, Oracle DBA
 
when you use mv it doesn't discard the source until it's gotten the source copied to the destination. i would suggest enahancing your script to check and see if there is enough space, if not, do nothing. additionally you could have the script check to see if either the dest or source file exists. you'd then know if it was successful based on which file still existed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top