[实践OK]shell年月日时分秒日志封装函数有必要,一行实现输出shell的年月日时分秒[2019/06/18 11:23:55],shell时间,shell创建文件,linux shell编写以日期时间为文件名的脚本学习笔记
echo [$(date +%Y/%m/%d\ %H:%M:%S)]
[2019/06/18 11:23:55]
sh funlog.sh
[2019/06/18 11:28:32]: INFO a message
=============================================================================
shell时间:
会生成俩文件:
/root/test_logtime.2819:26
来源:http://liubin.blog.51cto.com/282313/166927
[2019/06/18 11:23:55]
sh funlog.sh
[2019/06/18 11:28:32]: INFO a message
=============================================================================
shell时间:
a=`date +%Y%m%d`
echo $a;
echo $a;
# sh data.sh
20101028
20101028
#!/bin/sh
#log
MYDATE=`date +%d%m%y`
#append MYDATE to the variable LOGFILE that holds the actual filename of the log
LOGFILE=/root/test_log.$MYDATE
#create the file
>$LOGFILE
MYTIME=`date +%d%R`
LOGFILE2=/root/test_logtime.$MYTIME
#create the file
>$LOGFILE2
#log
MYDATE=`date +%d%m%y`
#append MYDATE to the variable LOGFILE that holds the actual filename of the log
LOGFILE=/root/test_log.$MYDATE
#create the file
>$LOGFILE
MYTIME=`date +%d%R`
LOGFILE2=/root/test_logtime.$MYTIME
#create the file
>$LOGFILE2
会生成俩文件:
ls /root/test_log.281010
/root/test_log.281010ls /root/test_logtime.2819:26
/root/test_logtime.2819:26
来源:http://liubin.blog.51cto.com/282313/166927
作者:jackxiang@向东博客 专注WEB应用 构架之美 --- 构架之美,在于尽态极妍 | 应用之美,在于药到病除
地址:http://jackxiang.com/post/3702/
版权所有。转载时必须以链接形式注明作者和原始出处及本声明!
最后编辑: jackxiang 编辑于2019-6-18 11:29
评论列表