Linux.com

How to Clear Memory Buffer ???

Link to this post 23 Nov 09

I am having a Oracle server installed on Linux server. I want to clear the buffers after a certain time interval. I use the following command for the same.

echo 3 > /proc/sys/vm/drop_caches

Can I have a script which will execute the above script after certain time interval OR a script which will execute the above command when certain memory size is reached.

Thanx & Regards.

Link to this post 24 Nov 09

You can schedule cron to run a script at specific interval testing the size of a chosen directory and running your command if the size has exceeded a predefined limit, an example script is below.


#!/bin/bash

DIR=${DIR:=/home}
LIMIT=78000000

cd $DIR
SZ=$(sudo du -c|grep total|cut -f 1)

if [ "$LIMIT" -le "$SZ" ];then
#echo "The dir is too large"
echo 3 > /proc/sys/vm/drop_caches
fi

Depending on your chosen distro the methods for invoking cron may be different, if we has that information we could assist further,

Link to this post 24 Nov 09

Oh, thanx man, I wanted it too. Now I wanted to create topic about this.

Link to this post 24 Nov 09

can i use the Code:

#!/bin/bash

DIR=${DIR:=/home}
LIMIT=78000000

cd $DIR
SZ=$(sudo du -c|grep total|cut -f 1)

if [ "$LIMIT" -le "$SZ" ];then
#echo "The dir is too large"
echo 3 > /proc/sys/vm/drop_caches
fi

also for an not Oracle Server?

Link to this post 24 Nov 09

zottelkind wrote:

can i use the Code:
also for an not Oracle Server?

Yesyou can use it for anything you want.

I posted the code for it to be public, you can use it to call to whichever command(s) you choose in cases when a size limit has been exceeded. If you are looking for a way to control quotas on users then you should check out http://www.ubuntugeek.com/how-to-setup-disk-quotas-in-ubuntu.html, that guide is for Ubuntu, if you are looking for a different distro then post it here and I can try to assist.

Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board