Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

This question already has an answer here:

I have a Linux server containing the os version below:

Linux 2.6.32-220.7.1.el6.x86_64

I want to restart it in every 2 days, please help me, I want to do it via crontab.

Another help,

I used a code below to drop my memory caches in every hour.

0 * * * * /root/clearcache.sh

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

But 1st 15 in every hour my server remain so slow after cleaning the caches. My sites do not load during every hour in 1st 15 minutes.

In another way if I restart my server then also caches are removed. So I decided to restart my server in every 2 days to drop my caches.

Will it be helpful to restart? Or is there any other way to drop my memory caches that will not down my server?

share|improve this question

marked as duplicate by Michael Hampton Aug 6 at 4:30

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

Why are you doing this? The caches are not a problem. Restarting won't fix whatever issue you're having. –  cjc Apr 15 '12 at 14:20
If you have a performance related problem, you need to know its cause first. Restart will not offer you anything! –  Khaled Apr 15 '12 at 14:21
I have 16GB ram, but if i clear my caches now, after 10 hours my caches are taking 10GB and using 5GB, so total 15GB is using, in that if i clear cache, it will free a lots of ram. Thanks. –  Barkat Ullah Apr 15 '12 at 14:26
Are you seeing this behavior? If so, it's not a problem: linuxatemyram.com –  Bill Weiss Apr 15 '12 at 14:34
If you don't want your system to use RAM, take it out of the system and sit it on your desk. The more RAM your system uses, the faster it goes. That's why we add RAM to a system! Why would you want your system to be forced to use less RAM and thus run more slowly?! –  David Schwartz Apr 15 '12 at 20:33

1 Answer 1

up vote 7 down vote accepted

To answer your headline question, in root's crontab

0 0 */2 * * reboot

would reboot your system at midnight every other day. There may be an extra reboot or an extra day between reboots for months with odd numbered days.

Having said that, dropping caches probably isn't the correct thing to do as they are generally used to speed things up. Have a look at some of the answers to this SF search which may be able to help you diagnose why your system is slow so you can fix the real problem.

share|improve this answer
Now it is super off peak hour, therefore i am sharing my # free -m screenshot. dl.dropbox.com/u/26967109/free-m.jpg . See that 6GB memory is used but 4 GB is cached –  Barkat Ullah Apr 15 '12 at 15:13
I think you should go read this website that @billweiss posted, repeatedly, until you understand what it is saying: linuxatemyram.com –  Magellan Apr 15 '12 at 15:22
OH, i just got my answer, If your applications want more memory, they just take back a chunk that the disk cache borrowed. Disk cache can always be given back to applications immediately! You are not low on ram! , that means cached memory will be free when my sites will be needed, is not it? –  Barkat Ullah Apr 15 '12 at 15:28
Exactly. That's exactly how that works. –  Magellan Apr 15 '12 at 15:29
Thanks a lot, i will not use any crontab to drop caches, it will help me so much from my hesitation and my sites will be faster from now. –  Barkat Ullah Apr 15 '12 at 15:31

Not the answer you're looking for? Browse other questions tagged or ask your own question.