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
dd if=/dev/zero of=vfs bs=1M count=20
# make a filesystem, with no reserved space, in that file
mkfs.ext3 -m 0 vfs
# create a mountpoint
mkdir /mnt/max20M
# mount the file
mount -t ext3 -o loop vfs /mnt/max20M
# let anyone access it
chmod 777 /mnt/max20M
Now you have your "folder" at
/mnt/max20M that cannot hold more than 20MB of files. Actually the number will be a little less than 20MB because the filesystem itself takes up some of that space. I'll let you work out how to adjust the
dd command if you want
exactly 20MB of storage space.