Generate file Shell script and description (i)

Source: Internet
Author: User
Tags mysql login

Generate file Shell script and Description:

#!/bin/sh

file1=$ (date +%y%m%d%h%m%s) #定义变量获取当前时间

ALM_TYPE=BOSS4ZC #定义变量

instance_id=62100408# Defining variables

status=major# Defining variables

Alm_info=mysql Standby Host Downtime 10.**.62.**, please deal with it in time. #定义变量

alm_time=$ (date + '%y-%m-%d%h:%m:%s ') #定义变量

File2= $INSTANCE _id. #定义变量

file3=.alm# Defining variables

File_name= $file 2$file1$file3# Defining variables

Cd/nms/almd/data/alm #进入固定路径

Touch $file _name #创建文件

Chown NMS $INSTANCE _id* #修改文件用户

Chgrp BOMC $INSTANCE _id* #修改文件组

echo $ALM _type ";" $INSTANCE _id ";" $STATUS ";" $ALM _info ";" $ALM _time >> $file _name #重定向到文件

File1_name= $file 2$file3 #定义变量

Touch $file 1_name #创建文件

if [!-F "$file 1_name"] #判断如果文件不存在

Then

echo "$host MySQL login successfully"

Exit 0

Else

#echo "$host mysql login faild"

mv/home/mysql/check_mysql_alarm.sh/home/mysql/check_mysql_alarm1.sh

Exit 2

Fi

#######################################################################

Configure timed execution scripts with the CRONTAB-E command:

* * * * * */nms/check_mysql.sh 1>/dev/null 2>&1

* * * * * */nms/check_mysql_ip.sh 1>/dev/null 2>&1

#每分钟执行一次/nms/check_mysql.sh Script

Note: The script executes manually: normal; crontab execution does not take effect;

Summary reason:

Absolute path problems in 1.shell scripts (especially for makefile paths)

2.CRONTAB environment variable problem (especially command call path)

------------------------------------------------------

# crontab config file!!!

------------------------------------------------------

[Email protected] scripts]# Cat/etc/crontab

Shell=/bin/bash

Path=/sbin:/bin:/usr/sbin:/usr/bin # Copy executable files to/usr/bin

Mailto=root

home=/


# for details see Mans 4 Crontabs


# Example of Job definition:

#.----------------Minute (0-59)

# |.-------------Hour (0-23)

# | |.----------DAY of Month (1-31)

# | | |.-------month (1-12) OR jan,feb,mar,apr ...

# | | | |.----DAY of Week (0-6) (sunday=0 or 7) or Sun,mon,tue,wed,thu,fri,sat

# | | | | |

# * * * * * * user-name command to be executed

-------------------------------------------------------------






This article is from "Dream Dreams" blog, please be sure to keep this source http://dreamy.blog.51cto.com/12471447/1906417

Generate file Shell script and description (i)

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.