shell脚本运行日志通用模块

php中文网
发布: 2016-06-07 15:59:55
原创
2002人浏览过

目标 实现记录shell执行的开始时间,结束时间,运行状态,错误信息等,以函数封装日志记录的方式,脚本调用函数 源码 通用函数脚本program_log_new.sh function init_log(){sqlplus -S test/passw0rd@orcl EOFinsert into program_log values($id,$day,$1, s

目标

实现记录shell执行的开始时间,结束时间,运行状态,错误信息等,以函数封装日志记录的方式,脚本调用函数

ViaooChain 维奥连锁招商网站系统
ViaooChain 维奥连锁招商网站系统

网站功能资讯模块资料模块会员模块产品展示模块产品订购模块购物车模块留言模块在线加盟模块多级后台管理系统网站环境本系统为 asp.net开发donet版本为1.1框架数据库为acdess2000授权方式为免费,本版本本地可直接运行(使用http://localhost或http://127.0.0.1访问)如需放到外网通过域名访问,则需通过qq联系我免费索取钥匙文件,将钥匙文件放到网站空间根目录即可

ViaooChain 维奥连锁招商网站系统 0
查看详情 ViaooChain 维奥连锁招商网站系统

源码

通用函数脚本program_log_new.sh
function init_log()
{
sqlplus -S test/passw0rd@orcl <<EOF
insert into program_log values($id,$day,'$1', sysdate,null,'S',null);
commit
exit
EOF
}
function modify_status(){
sqlplus -S test/passw0rd@orcl <<EOF
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 user/1234@test <<EOF
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                                       //发生异常,调用异常,程序退出
登录后复制
最佳 Windows 性能的顶级免费优化软件
最佳 Windows 性能的顶级免费优化软件

每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号