-2

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
  • Which part of this are you having problems with? – Sobrique Mar 07 '15 at 09:10
  • Would probably get more help if you actually asked some questions. The more specific the better (and preferably with context, what you have tried and what problems you encountered). – kaylum Mar 07 '15 at 10:49
  • possible duplicate of [Automatically kill process that consume too much memory or stall on linux](http://stackoverflow.com/questions/187804/automatically-kill-process-that-consume-too-much-memory-or-stall-on-linux) –  Mar 07 '15 at 19:05

1 Answers1

-2

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

hariK
  • 2,722
  • 13
  • 18