Skip to content

Instantly share code, notes, and snippets.

@pandanote-info
Last active April 23, 2019 15:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pandanote-info/3182327b1584d76d26910f0feb28a024 to your computer and use it in GitHub Desktop.
Save pandanote-info/3182327b1584d76d26910f0feb28a024 to your computer and use it in GitHub Desktop.
MariaDBのプロセスがOOMKillerにkillされる等の理由で動いていなかった場合に再起動を行い、それをTwitterに起動するためのプログラムを起動するシェルスクリプト。
#!/bin/sh
CHECK_CMD=`ps ax | grep mysqld | grep -v grep`
CURRENT_DIR=`pwd`
CURRENT_TIME=`date +%Y%m%d%H%M%S`
CHECK_CMD=
if [ -z "${CHECK_CMD}" ]; then
systemctl restart mariadb
if [ "$?" = 0 ]; then
python3 ${CURRENT_DIR}/sqlcheck_publisher.py
fi
fi
find /var/log/sqlcheck -atime +30 -exec rm -f '{}' \;
touch /var/log/sqlcheck/sqlcheck_${CURRENT_TIME}.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment