奇怪的print progname ":\n"日志

[root@xxxxxxxx /home/ahao.mah]
#tail /var/log/messages -f
Feb 10 10:01:01 csaccurate-49-5011                 }
Feb 10 10:01:01 csaccurate-49-5011                 { print; }
Feb 10 11:01:01 csaccurate-49-5011                 print progname ":\n"
Feb 10 11:01:01 csaccurate-49-5011                 progname="";
Feb 10 11:01:01 csaccurate-49-5011                 }
Feb 10 11:01:01 csaccurate-49-5011                 { print; }
Feb 10 11:01:01 csaccurate-49-5011                 print progname ":\n"
Feb 10 11:01:01 csaccurate-49-5011                 progname="";
Feb 10 11:01:01 csaccurate-49-5011                 }
Feb 10 11:01:01 csaccurate-49-5011                 { print; }

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
[root@node2 ~]# cat /usr/bin/run-parts
#!/bin/bash
# run-parts - concept taken from Debian
# keep going when something fails
 set +e
if [ $# -lt 1 ]; then
        echo "Usage: run-parts <dir>"
        exit 1
fi
   if [ ! -d $1 ]; then
        echo "Not a directory: $1"
        exit 1
   fi
# Ignore *~ and *, scripts
   for i in $1/*[^~,] ; do
          [ -d $i ] && continue
    # Don't run *.{rpmsave,rpmorig,rpmnew,swp} scripts 排除一些格式的文件
          [ "${i%.rpmsave}" != "${i}" ] && continue
          [ "${i%.rpmorig}" != "${i}" ] && continue
          [ "${i%.rpmnew}" != "${i}" ] && continue
          [ "${i%.swp}" != "${i}" ] && continue
          [ "${i%,v}" != "${i}" ] && continue
          
    # 执行 /etc/cron.daily/的具有可执行权限的文件。
          if [ -x $i ]; then
                  $i 2>&1 | awk -v "progname=$i" \
                                'progname {
                                     print progname ":\n"
                                     progname="";
                                 }
                                 { print; }'
          fi
  done
  exit 0
  说明:
      脚本 run-parts 是先判断目录/etc/cron.daily 的文件,符合条件的再让它去执行。
  查看 /etc/cron.daily/logrotate 任务脚本
  [root@node2 ~]# cat /etc/cron.daily/logrotate
  #!/bin/sh
  /usr/sbin/logrotate /etc/logrotate.conf
  EXITVALUE=$?
    if [ $EXITVALUE != 0 ]; then
        /usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]"
    fi
 exit 0

http://9528du.blog.51cto.com/8979089/1425575

转载于:https://www.cnblogs.com/muahao/p/6385664.html

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值