how to break copy process when folder size reaches its maximum
Hi all,
I have written a script. #/bin/bash a=`du -sh /root/samplefolder | cut -f1` echo $a > testfile sed -i 's/M//g' testfile b=`cut -f1 testfile` if [ $b -ge 20 ] then echo size of samplefolder reaches 20M so cannot copy files to that folder chattr +i /root/samplefolder else echo size for samplefolder is lessthan 20M fi The aim of this script is, when the folder reaches 20M then attributes will be set to that particular folder so that no newfiles and folders cannot be created or copied to that samplefolder. i run the script every second with the help of LQ member suggestion. whenever i copy a file morethan 20M to that folder its getting copied fully and then the attributes were applied. But i dont want this to happen, when the folder reaches its maximum current write operation to that folder should be stopped automatically with a error. How to do this. Kindky post your suggestions. Thanks in advance, Dinesh. |
I think you are going about this the wrong way.
What you can do is create and mount a filesystem of size 20MB. You can then copy files to it until it reaches 20MB and then the last operation will fail because "no space left on device". This is more efficient than running a script every second. As root: Code:
# create a 20MB file |
Or use some quota tool, it was created for that purpose.
|
hi tredegar,
If i need to extend the size can i do that with out un mounting. If possible kindly post me the code. |
Quote:
|
thanks tredegar for your suggestion.
|
All times are GMT -5. The time now is 08:06 PM. |