linux中脚本的日志,shell 脚本运行日志通用模块

function init_log()

{

sqlplus -S [email protected] <

insert into program_log values($id,$day,'$1', sysdate,null,'S',null);

commit

exit

EOF

}

function modify_status(){

sqlplus -S [email protected] <

update program_log set program_status='$1',end_date=sysdate where id=$id;

commit

exit

EOF

}

function exception_write(){

if [ $? -ne 0 ]

then

modify_status $status2

exit 1

fi

}

function finish_write(){

if [ $? -eq 0 ]

then

modify_status $status1

#modify_status $1 $2 $3

else

# modify_status $1 $2 $3

modify_status $status2

exit 1

fi

}

status1=C

status2=F

day=`date "+%Y%m%d"`

id=`sqlplus -S [email protected] <

set heading off

select program_log_seq.nextval from dual;

commit

exit

EOF`#!/bin/sh

. ~/.bash_profile

source program_log_new.sh //公用脚本

init_log sh_xx //初始化日志函数调用,传入程序名

shell命令xxx 2>${logdir}/xx_$time.log

exception_write //发生异常,调用异常,程序退出

shell命令xxx 2>${logdir}/xx_$time.log

exception_write //发生异常,调用异常,程序退出

....

shell命令xxx 2>${logdir}/xx_$time.log

finish_write //发生异常,调用异常,程序退出

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值