Linux scheduled monitoring and maintenance services

Source: Internet
Author: User

Linux scheduled monitoring and maintenance services

Taking the encryption and decryption service as an example, I provide the encryption and decryption service. Others call my service. Because Linux machines are remote, I don't know where the machines are in a specific environment, I don't know if the machine is restarted. I need to maintain the stability of my services. What should I do?

Two things need to be done

1. scheduled task, executed once per minute

---------------------------------------------------------- Command ----------------------------------------------------------

Crontab-e

* ****/Mnt/disk/xxx/encrypt-decrypt-service-moniter.sh

Bytes --------------------------------------------------------------------------------------------------------------------

Note: It must be reloaded. Otherwise, the latest task may not be executed.

Sudo service cron reload (ubuntu)
/Sbin/service crond reload (redhat, centos)

2. Task content

Determine whether the service is running. if the service is not running, start the task. Note: The script must use the full path; otherwise, problems may occur.

------------------------------------------------------------ Code ----------------------------------------------------------

#! /Bin/sh
# Monitor whether the service is running normally. if the service is not running properly, enable the service.
Flag = $ (jps-l | grep "encrypt-decrypt ")
If [-n "$ flag"]; then
Echo "service is good, don't warry"
Else
Date + % Y % m % d "" % H: % M: % S>/mnt/disk/mashangrong/restart. log
Echo "service is restart by encrypt-decrypt-service-moniter.sh">/mnt/disk/mashangrong/restart. log
Setsid java-jar/mnt/disk/mashangrong/encrypt-decrypt-1.0.0_v1026.jar-Xmx4096m-Xms4096m-XX: NewRatio = 1-XX: Export vorratio = 8
Fi

Bytes --------------------------------------------------------------------------------------------------------------------

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.