shell常用函数封装-main.sh

#!/bin/bash

#sunlight sp monitor system
#created on 2018/01/07
#by chao.dong
#used by sp servers consist of 1 manage server and 3 application servers

 

function get_current_time_stamp()
{
echo `date "+%Y/%m/%d %H:%M:%S"`
}

function send_error()
{
echo -e "\e[1;45m [ Error ] `get_current_time_stamp` - $1 -\e[0m"
}

function send_success()
{
echo -e "\e[1;32m [ Success ] `get_current_time_stamp` - $1 -\e[0m"
}

function send_info()
{
echo -e "\e[1;34m [ Info ] `get_current_time_stamp` - $1 -\e[0m"
}

function send_warn()
{
echo -e "\e[1;33m [ Warn ] `get_current_time_stamp` - $1 -\e[0m"
}

export get_current_time_stamp
export send_error
export send_success
export send_info
export send_warn

posted on 2018-02-17 01:32  天涯飞鸿  阅读(3351)  评论(0编辑  收藏  举报

导航