알짜게시판

웹서버 상태 확인 후 자동 재시작 쉘 스크립트

  1. ServerMonitor.sh 파일 생성
#!/bin/bash

status=$(curl -s -o /dev/null -w "%{http_code}" localhost)

if [ $status -eq 502 ]; then
  systemctl restart php-fpm.service
elif [ $status -ne 200 ]; then
  systemctl restart httpd.service
fi
  1. ServerMonitor.sh 권한 설정
chmod 700 ServerMonitor.sh
  1. cron 에 등록하여 1분마다 상태 확인
crontab -e

* * * * * /root/ServerMonitor.sh >& /dev/null
  1. cron 재시작
systemctl restart crond.service

로그인 후 댓글내용을 입력해주세요

제목 글쓴이 조회 날짜
리눅스 Apache 웹 로그 분석하기 – awk와 GoAccess 활용 18,388 25-10-28
리눅스 PHP 파일 업로드 용량 늘리기 56,467 25-10-03
리눅스 구글 크롬 콘솔 'Attestation check for Topics on' 에러 원인 &… 60,801 25-04-11
리눅스 PHP-FPM 튜닝을 위한 메모리 계산 42,114 24-08-29
리눅스 데몬(systemd service) 작성 및 실행하기 66,806 24-03-14
리눅스 메일(Mail) 삭제/초기화 58,960 23-07-18
리눅스 PHP 버전 추가하기 35,344 23-04-29
리눅스 yum 에서 Thread died in Berkeley DB library 오류 59,909 22-09-18
리눅스 VNSTAT 설치하기 56,824 22-09-17
리눅스 로그 삭제 및 비우기(?) 58,998 22-09-09
리눅스 .htaccess 를 이용해서 https 이동하기 45,978 22-08-31
리눅스 윈도우 프로그램 실행 (centos7, wine 7.0) 45,808 22-08-09
리눅스 웹서버 상태 확인 후 자동 재시작 쉘 스크립트 41,798 22-02-28
리눅스 Composer 설치하기 2,469 20-07-06
리눅스 Swap 생성/수정 2,798 19-09-04
리눅스 바이러스 검사 2,598 19-09-04
리눅스 간단한 보안 체크하기 2,510 19-06-05
목록
망치와삽강남언니야청년돈길IT기술결혼의정석