Want to make a shell script that runs a program, then if the memory reach over specific limit(example 3gb), it shutdown and restart itself.
- While running
- If memory > 3gb
- Shutdown
- Restart
Want to make a shell script that runs a program, then if the memory reach over specific limit(example 3gb), it shutdown and restart itself.
MEM_LIMIT=3145728
MEM_USED=$(cat /proc/meminfo | grep "MemFree" | awk -F' ' '{print $2}' | tr -d " ")
if [ $MEM_USED -ge $MEM_LIMIT ]
then
reboot 0
fi