$ cat totalmem_check.sh
#!/bin/sh
# メモリ使用率が引数を上回っていたら偽(1)を返す
total=$(free | awk '/Mem/{print $2;}')
free=$(free | awk '/buffers\/cache/{print $4;}')
result=$((100 - 100 * ${free} / ${total}))
test ${result} -le $1
$ ./totalmem_check.sh 70
$ echo $?
0
$ ./totalmem_check.sh 60
$ echo $?
1
More than 5 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme
List of users who liked
1010