奇怪的print progname “:\n”日志

奇怪的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

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/108667.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号