OPENWRT自动清理内存,openwrt 自动清理内存要怎么弄?
很多人都使用OPENWRT/LEDE 做ARIA2下载,然后就是使用samba,共享文件给电视,看电影,也就是做一个家庭媒体中心,不过有些路由器系统中SAMBA共享看电影的时候,内存不断的下降,虽然本质是LINUX系统的路由,内存管理方式和WIN不一样,但是经过观察,确实不会恢复内存,而且低于100后,系统会变慢,登录路由反应都很慢。所以还是有必要自动清理内存。方法如下:
1.建立SH脚本文件填入如下命令:
#!/bin/sh used=`free -m | awk 'NR==2' | awk '{print $3}'` free=`free -m | awk 'NR==2' | awk '{print $4}'` echo "===========================" >> /var/log/mem.log date >> /var/log/mem.log echo "Memory usage | [Use:${used}KB][Free:${free}KB]" >> /var/log/mem.log if [ $free -le 153600 ] ; then sync && echo 1 > /proc/sys/vm/drop_caches sync && echo 2 > /proc/sys/vm/drop_caches sync && echo 3 > /proc/sys/vm/drop_caches echo "OK" >> /var/log/mem.log else echo "Not required" >> /var/log/mem.log fi
具体作用就是,查询当前内存剩余量,然后清理内存。这里是153600也就是150M以下清理,这里先运行sync,可以防止数据丢失。
保存后,放在路由器上,例如保存为以下路径:/root/memclean.sh
然后设置定时运行:
修改 /etc/crontabs/root 文件,添加一行
*/1 * * * * /root/memclean.sh
表示1分钟检测一次内存余量,低于150M 就清理!!!
还有一些智能路由的经验可以查看以下分类
智能路由分类
It is the best time to make some plans for the future
and it is time to be happy. I have read this submit
and if I could I desire to counsel you few fascinating issues
or tips. Perhaps you can write subsequent articles relating to this article.
I desire to read more things approximately it!
Way cool! Some very valid points! I appreciate you penning this post plus the rest of the website is also very good. Joice Benito Lathan
This piece of writing is genuinely a nice one it assists new internet people, who are wishing for blogging. Dawn Hewie Spragens
Hi, this weekend is good in favor of me, as this time i am reading this great informative article here at my residence. Cinnamon Moses Nita
Very good blog article. Really looking forward to read more. Really Great. Drona Maurise Pearce
I really enjoy the blog post. Really looking forward to read more. Fantastic. Hannah Hayden Seltzer
I am regular visitor, how are you everybody? This piece of writing posted at this web site is genuinely nice. Celina Igor Steinway
I all the time used to study article in news papers but now as I am a user of web thus from now I am using net for articles, thanks to web. Rozella Kippie Kirk
I visited several sites except the audio feature for audio songs present at this web site is actually wonderful. Breanne Irving Romilda
I am actually grateful tto the holder of this web site who has shhared this fantastic piece of writing at at this place. Trista Raul Michell
You made some decent points there. I did a search on the topic and found most persons will go along with with your site. Blanch Wilhelm Lindner
I regard something truly special in this web site. Gwen Otto Liddie
There is significantly a package to know about this. I presume you made sure nice factors in features likewise. Joscelin Dallon Gustafson