Centos how to free memory with crontab

centosmemory

My system is Centos 5.5 with 2G memory, I have no permission setup a swap. I have set restart mysqld, httpd in 3:00 every day with crontab, and I also want to free memory every hour.

So how to free memory with crontab? I write some code below styding from web, but it seems not work…

crontab -e

6 * * * * sync;echo 3 > /proc/sys/vm/drop_caches

EDIT here is my.cnf, however I need fulltext search sometimes used oderby date.

key_buffer_size = 256M
max_allowed_packet = 8M
max_connections=1024
wait_timeout=5
table_open_cache = 512
sort_buffer_size = 2M
read_buffer_size = 2M
read_rnd_buffer_size = 2M
myisam_sort_buffer_size = 256M
thread_cache_size = 8
query_cache_limit=2M
query_cache_size= 128M
thread_concurrency = 8
read_rnd_buffer_size=2M
tmp_table_size=128M
ft_min_word_len=2
ft_max_word_len=42

Best Answer

The code you cited will cause the kernel to discard any cached data it has ... which is exactly the memory that it would have discarded as soon as anything wanted to use more memory anyhow. It will have no practical effect on your system.

Ultimately, other than running less software, or restarting processes, there is nothing you can do to reclaim extra memory. Linux has no mechanism to signal memory pressure to an application before killing it as "out of memory".