[HOW TO} Clear Cache memory

Share your awesome tips and tricks here.
Elrique64
Posts: 222
youtube meble na wymiar Warszawa
Joined: Wed Feb 26, 2014 5:26 am

[HOW TO} Clear Cache memory

Post by Elrique64 »

Been working on this lock up issue I've been having with my AS-202T. In one of the replies I received I got a line of code that runs in a terminal session to clear the cache memory. Since I started using it I haven't had a crash... (Crossing my fingers...) :)

So, what I did was take that line of code and make a script with it. Nothing fancy, in fact it's kinda ugly, but it works, so going to put it here so others can implement it if they want to. This is the file I created and the folder I put it in: /volume1/misc/clearcache.sh

Code: Select all

#!/bin/sh

sync; echo 3 > /proc/sys/vm/drop_caches
#    echo "Clearing Cache.." >> /volume1/misc/clearcache.log
#    date >> /volume1/misc/clearcache.log
This clears the cache out, but we need to call it now... The easiest way to do this is through cron. So we need to navigate to the crontab folder and open the file. With WinSCP or another tool like it go to this path:

/var/spool/cron/crontabs/root (Notice the file name is root with no extension!!!)

Add this line to make the script run every 5 minutes to clear the cache.

Code: Select all

*/5   *   *   *   *   /volume1/misc/clearcache.sh
When I first ran this script I had the two extra #'s missing in the echo and date lines. This made a file named clearcache.log that has the date and time and the fact that it's clearing the cache. After you are sure this is working, put the 3"s back in to comment them out, so they don't make a HUGE file you got to delete later on...

I'm not making ANY PROMISES here, and part of this is actually from Albert Xui from Asustor. I just took his idea and made the script and the cron job. If it works, drop a line here and let us know you aren't locking up any more...
User avatar
Kapitein Haak
Posts: 333
Joined: Tue Oct 15, 2013 2:40 pm
Location: Stranded on the Dutch coast.

Re: [HOW TO} Clear Cache memory

Post by Kapitein Haak »

As this may resolve the problem Elrique64 has (and if it does Asustor should look into memory settings/configurations very hard) it does bring down the performance of the NAS. Cache memory has it's function (to serve data from RAM instead of the disk when it's available and serve it a LOT faster) so use the script Elrique64 has posted, but only when suffering from the hangs described by Elrique64. If the script works this should by a temporary solution until fixed in firmware.

Best regards,
Kapitein Haak.
"What would the world be like without Captain Hook?"
---
"Homo sapiens non urinat in ventum" (A wise man doesn't piss into the wind), only in Amsterdam:
https://www.google.nl/maps/@52.36289,4. ... 312!8i6656
Elrique64
Posts: 222
Joined: Wed Feb 26, 2014 5:26 am

Re: [HOW TO} Clear Cache memory

Post by Elrique64 »

Agreed. I should have been more clear in that regard, thanks Kapitien...