Is it possible? A script to check free RAM and reboot if it is less than a limit
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Is it possible? A script to check free RAM and reboot if it is less than a limit
Can i write a script which monitor RAM free space by 'free -m' command, and if the free space is less than certain limit, it should reboot the system.
I tried free -m the result was
total used free shared buffers cached
Mem: 249 60 189 0 15 26
-/+ buffers/cache: 18 231
Swap: 509 0 509
we should cut the column 'free' as an integer value. Is it possible? Am i moving in a right angle? Please suggest me....
Yes of course it is possible, but it is almost certainly not the right approach. Linux aggressively assigns RAM to the IO cache, so there is rarely very much RAM free, even right after reboot.
If you have some process which is hogging all your memory, killing that process (or fixing the program not to hog resources) a better solution.
Last edited by matthewg42; 11-22-2007 at 10:38 PM.
Reason: typo : hod -> hog
When i used cat command, the answer was
total used free shared buffers cached
Mem: 249 60 189 0 15 26
Swap: 509 0 509
when i use 'cut -f1 temp.txt'
Entire file was printing
When i use 'cut -d: -f1 temp.txt'
total used free shared buffers cached
Mem
Swap
when i use 'cut -d: -f2 temp.txt
total used free shared buffers cached
249 60 189 0 15 26
509 0 509
likewise i cant get what i want. I think i have to change my direction. Is there any other ......?
Sorry but it is a Mail server.We r using Centos 4.5 with qmail. The problem is it is taking all memory then takes from swap when that too empty, It is telling "out of memory" Then it is hanging. It is not stable even 24 hours. Now using cron, We r rebooting daily at 5.00 am. To over come only i tried this way... Is there any other ways?
Yes; Find the underlying problem and fix it. Rebooting a mail server every 24 hours is not something you want to do.
I honestly cannot tell you more then that without knowing more. Out of memory errors can be caused by a whole range of things, from hardware that is to 'light' to handle the actual load to memory leaks to bad configuration to.........
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.