
사용 가능한 메모리가 Xmb 미만인 경우 명령을 실행할 수 있도록 사용된 메모리 또는 사용 가능한 메모리를 확인하는 배치 스크립트를 작성하고 싶습니다.
Google을 검색했지만 그들이 참조하는 페이지가 작동하지 않습니다. Centos 7을 사용하고 있습니다.
기본적으로 하고 싶은 일
if availablememory < 26000m
do command=forever stopall
do command=pkill -f checkurl.php
end
BEFORE PROGRAM START
[root@www ~]# free -m
total used free shared buff/cache available
Mem: 32002 3471 802 1121 27728 26529
Swap: 38112 234 37878
[root@www ~]#
AFTER PROGRAM START
[root@www ~]# free -m
total used free shared buff/cache available
Mem: 32002 13913 200 1121 17887 16381
Swap: 38112 234 37878
답변1
if [ $(awk '/^MemAvailable:/ { print $2; }' /proc/meminfo) -lt 123456 ]; then
: do someting
done