Results 1 to 7 of 7
If I have a file in which data is written which leads to the increase of this file size
Is it possible to make a constraint such that this file ...
- 06-23-2011 #1Just Joined!
- Join Date
- Jun 2011
- Posts
- 2
how to make constraints on the size of any file
If I have a file in which data is written which leads to the increase of this file size
Is it possible to make a constraint such that this file size mustn't exceed certain size
let say 5 MB for instance
Thanks in advance
- 06-23-2011 #2Linux Guru
- Join Date
- Oct 2007
- Location
- Tucson AZ
- Posts
- 1,940
The site below gives an explanation of how to do this:
File size limit exceeded error under Linux and solution
- 06-24-2011 #3
limits.conf fsize sets limits per user, per group, or globally for _any_ file, not specific files. Although the thread title says "any file", the OP seems to want to apply specific files. I don't know the answer.
- 06-26-2011 #4Just Joined!
- Join Date
- Jun 2011
- Posts
- 2
actually yes it not for all files it's for certain files
so you are telling me here that it can be done for user or group so how can this be done
for certain user ? or certain group ?
- 06-26-2011 #5
I'm saying that the link Yancek posted does _not_ show how to do it for specific files, only globally for all files. Maybe he'll check back in with more help.
- 06-27-2011 #6Linux Engineer
- Join Date
- Apr 2006
- Location
- Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
- Posts
- 1,117
Hi.
More information would be useful.
What do you think should happen if a file exceeds the specified size? Abort, exit gracefully, fill up another file, rotate among n files (keeping the last n), etc.?
One way you can do it is to create a filesytem of a certain size. For testing I often have:
So if you are using LVM that is fairly easy.Code:Filesystem Size Used Avail Use% Mounted on /dev/md2 7.6M 1.1M 6.1M 15% /small
Another way is to require the use of a filter (that you would write) that does something when the limit is reached:
Best wishes ... cheers, drlCode:./a.out | my-size-limit 5M
Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
We look forward to helping you with the challenge of the other 10%.
( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )
- 06-28-2011 #7Just Joined!
- Join Date
- Sep 2010
- Location
- Dhaka, Bangladesh
- Posts
- 29
I don't know whether this will help, but it's worth checking
http://sarmed-quota.blogspot.com
7. Set quota for user Harry so that when user Harry types dd=/dev/zero of=file bs=1024K count=4 he succeeds, but when he types dd=/dev/zero of=file bs=1024K count=8 he fails.
The command dd=/dev/zero of=file bs=1024K count=4 creates a file that is 4KB in size. Count=8 creates a 8KB file. So, we have to define quota so that soft limit is 4KB and hard limit is 8KB.
Because we have to define quota for a user, we have to implement quota to the partition containing his home directory. If there is no /home partition, we implement quota in / partition.
#df –h //to find out the partition containing /home
vim /etc/fstab
/dev/hdaX /home ext3 defaults,quota 0 0
add
#mount -o remount //remounts all the partitions;-o==options
#quotacheck -cM /home //-c==check, -M==modify
#quotaon /home
#edquota Harry //edit quota for user Harry….all information here is in kilobytes
partition blocks soft hard inode soft hard
/dev/hdaX do not edit 4096 8192 do not edit do not edit do not edit
#repquota -v /home //report quota verbosely for /home
OR
#repquota –va //reports all existing quotas


Reply With Quote