| #!/bin/sh |
| |
| sigterm() |
| { |
| echo "******memopt is killed, I want back******" |
| exit 1 |
| } |
| |
| trap sigterm TERM |
| |
| start_time=$(date +%s) |
| while true; do |
| echo 3 > /proc/sys/vm/drop_caches |
| echo 1 > /proc/sys/vm/compact_memory |
| end_time=$(date +%s) |
| elapsed_time=$(($end_time -$start_time)) |
| if [ "$elapsed_time" -ge 35 ]; then |
| # 5 sec for slow scheduling tolerance. |
| # 35 sec = 20 sec sleep interval + 3 * 5. |
| echo "Slow response, thrashing? recover..." |
| stop catawampus |
| sleep 5 |
| start catawampus |
| fi |
| start_time=$(date +%s) |
| sleep 20 |
| done |