服务老是自己挂,还是内存溢出,得,无人值守,自己重启吧
#!/bin/bash
OUTOFMEMORY=$(tail -n100 ./chat.log | grep "OutOfMemoryError" | grep "UncaughtExceptionHandler" | grep -v "resp")
if [[ ! -z $OUTOFMEMORY ]]; then
./api.sh stop
sleep 2
./api.sh start
# Get current date and time
NOW=$(date +"%m-%d-%Y %T")
echo "Restarted due to OutOfMemoryError on $NOW" >> ./restart.log
fi
然后配置 crontab -e
* * * * * cd /opt/sh;/opt/webapp/api/auto.sh