If you run mysql, nginx, php in one server, it may cause out of memory, mysqld server will down cause of that, here, I get three scripts for checking my server.(nginx | apache)

1.Check MySQL

vim /your_path/checkmysql.sh

2.Check httpd

vim /your_path/checkhttpd.sh

3.Check nginx

vim /your_path/checknginx.sh

4.Check php-fpm

vim /your_path/checkphpfpm.sh

5.Add x for script

cd your_path
chmod +x *
Or you can add by one.

6.Add crontab

Notice, your server won’t cover nginx and apache, right? So, the script for crontab should not add all.

crontab -e

2 Replies to “Script for checking status of mysql | httpd | nginx | php-fpm

  1. Your command is reversed, so work would have to look like this:

    #!/bin/bash
    checknginx=pgrep nginx
    if [ -n “$checknginx” ]; then
    date=$(date +”%Y-%m-%d %H:%M:%S”)
    systemctl start nginx.service
    echo ‘Error: nginx at ‘ $date
    else
    echo ‘Nginx is Running, it is fine! verified at’ $date
    fi

发表评论

电子邮件地址不会被公开。 必填项已用*标注