Please create an account to participate in the Slashdot moderation system

 



Forgot your password?
typodupeerror
×
User Journal

Journal GameboyRMH's Journal: Live system RAM testing script

Here's a memory-testing script I wrote for my home server. Normally if you have a computer with non-ECC RAM you notice bad RAM when the computer acts insane - random crashes, files getting corrupted for no apparent reason, things like that. This will run a memory test while your OS is up and running, using whatever free RAM is available minus a reserve amount. You need to have memtester installed to use this script. I set mine to run once a week, it will peg your CPU and of course consume a lot of RAM while running.

#! /bin/bash
 
logfile='/var/log/memreport'
date +'%c' > $logfile
free -h >> $logfile
#Amount of RAM in MB to leave free when testing:
reserveram=256
#Get free RAM
freeram=`free -m | grep Mem | sed 's/\s\+/,/g' | cut -d , -f4`;
cachedram=`free -m | grep Mem | sed 's/\s\+/,/g' | cut -d , -f7`;
testram=`expr $freeram + $cachedram - $reserveram`;
if [ $testram -gt 0 ]
then
        memtester `echo -n $testram`M 1 >> $logfile
else
        echo "Insufficient free RAM for test" >> $logfile
fi
#----Check for errors and put warning in Issues file---
ERRORS=`grep -i fail $logfile`
if [ -n "$ERRORS" ]
then
        echo "\n WARNING - Memory Errors! \n" >> /etc/issue.custom
fi

Thanks to ASLR it will test a practically random sampling of the majority of your available RAM every time it runs, and hopefully catch any errors early on.

This discussion has been archived. No new comments can be posted.

Live system RAM testing script

Comments Filter:

I've noticed several design suggestions in your code.

Working...