shell 脚本执行日志通用模块
目标
实现记录SHELL执行的開始时间,结束时间。执行状态,错误信息等,以函数封装日志记录的方式,脚本调用函数
源代码
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 //发生异常,调用异常,程序退出
shell 脚本执行日志通用模块的更多相关文章
- [转]shell脚本打印日志方法
该文章转自:http://blog.csdn.net/wylfengyujiancheng/article/details/50019299 ----------------------------- ...
- windows下建立文件的换行符^M导致linux下的shell脚本执行错误的解决方式
常常在windows下编辑的文件远程传送到linux下的时候每行末尾都会出现^M.这将导致shell脚本执行错误,主要是由于dos下的编辑器和linux下的编辑器对文件末行的回车符处理不一致导致. 主 ...
- 远程shell脚本执行工具类
/** * 远程shell脚本执行工具类 */public class RemoteShellExecutorUtils { private static final Logger logger = ...
- shell脚本执行错误 $'\r':command not found
shell脚本执行错误 $'\r':command not found Linux下有命令dos2unix 可以用一下命令测试 vi -b filename 我们只要输入dos2unix *.sh就可 ...
- 用java代码调用shell脚本执行sqoop将hive表中数据导出到mysql
1:创建shell脚本 touch sqoop_options.sh chmod 777 sqoop_options.sh 编辑文件 特地将执行map的个数设置为变量 测试 可以java代码传参数 ...
- 2.8 补充:shell脚本执行方法
bash shell 脚本的方法有多种,现在作个小结.假设我们编写好的shell脚本的文件名为hello.sh,文件位置在/data/shell目录中并已有执行权限. 方法一:切换到shell脚本 ...
- 如何把rc.local里执行的shell脚本的日志内容放到其他位置
rc.local的日志内容默认是/var/log/boot.log /etc/rc.d/rc.local文件的文件头是#!/bin/sh ,我们把这修改成#!/bin/sh -x,这样系统启动后就会把 ...
- 用 shell 脚本做日志清洗
问题的提出 公司有一个用户行为分析系统,可以记录用户在使用公司产品过程中的一系列操作轨迹,便于分析产品使用情况以便优化产品 UI 界面布局.这套系统有点类似于 Google Analyse(GA),所 ...
- linux下shell脚本执行jar文件
最近在搞一个shell脚本启动jar文件个关闭jar文件的东东.搞得我都蛋疼了.今天晚上终于弄好了 话说,小弟的linux只是刚入门,经过各方查资料终于搞定了.话不多说,下面开始上小弟写的shell脚 ...
随机推荐
- python 处理cookie简单很多啊 httpclient版本是4.3.3
模拟登录流程: 1 请求host_url 2 从host_url中解析出 隐藏表单 的值 添加到POST_DATA中 3 添加账户,密码到POST_DATA中 4 编码后,发送POST请求 要点 ...
- hbase rowkey设计的注意事项
充分利用有序性 1.1 如果要scan操作,且不是很频繁,可以利用rowkey的有序性将需要一起扫描的数据放到一起.例如直接用时间戳.这样就可以按时间scan了.这个只要是简单的全表扫描都行. 1.2 ...
- 计算几何模板 (bzoj 1336,poj 2451 ,poj3968)
poj 3968 (bzoj 2642) 二分+半平面交,每次不用排序,这是几个算几版综合. #include<iostream> #include<cstdio> #incl ...
- 断命windows上卸载node并重装
抠门儿世界500强给前端开发人员用windows windows不支持n模块没法自动升级 不记得何时安装的旧版本node连个uninstaller都找不到 绕道安装nvm path也自动加进去了丫命令 ...
- Tmux:终端复用器
转自Tmux:终端复用器 Tmux 是一个 C 语言编写的终端,它能够在单一窗口中同时访问和控制多个终端.它是一个类似于GNU Screen 的工具.使用它,用户可以在 Linux 系统上管理多个任务 ...
- ANDROID_MARS学习笔记_S03_005_Geocoder、AsyncTask
一.代码1.xml(1)AndroidManifest.xml <uses-permission android:name="android.permission.ACCESS_FIN ...
- 2-3 tree使用
The 2-3 tree is also a search tree like the binary search tree, but this tree tries to solve the pro ...
- Java中int与Integer
一般小写字母开头的是数据类型(如int double),大写字母开头的一般是封装为类(如Double),里面有很多方法,比如实行转换Integer.parseInt(arg0),可以把其他类型的数据转 ...
- What exactly is the difference between WndProc and DefaultWndProc?
Control.DefWndProc Sends the specified message to the default window procedure. 参数说明:m:The Windows M ...
- Node.js权威指南 (12) - Node.js中的其他模块
12.1 使用dns模块解析域名 / 313 12.1.1 使用resolve方法将域名解析为DNS记录 / 313 12.1.2 使用lookup方法查询IP地址 / 315 12.1.3 使用re ...