A simple shell script that generates files in a fixed format
#! / bin/sh
File1=$ (date +% Y%m%d%H%M%S) # defines a variable to get the current time
ALM_TYPE=BOSS4ZC # define variables
INSTANCE_ID=62100408# defines variables
STATUS=MAJOR# defines variables
ALM_INFO=Mysql standby host downtime 10.09.62. Please deal with it in time. # define variables
ALM_TIME=$ (date +'% Y-%m-%d% HRV% MVA% S') # define variables
File2=$INSTANCE_ID.# defines variables
File3=.alm# defines variables
File_name=$file2 $file1 $file3# defines variables
Cd / nms/almd/data/alm # enters a fixed path
Touch $file_name # create file
Chown nms $INSTANCE_ID* # modify file user
Chgrp bomc $INSTANCE_ID* # modify filegroup
Echo $ALM_TYPE ";" $INSTANCE_ID ";" $STATUS ";" $ALM_INFO ";" $ALM_TIME > > $file_name # redirect to file
File1_name=$file2 $file3 # defines variables
Touch $file1_name # create file
If [!-f "$file1_name"] # judge if the file does not exist
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