奇怪的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
muahao@aliyun.com