我知道date -s <STRING>命令设置stringSTRING描述的时间。
我想要的是每当它被用来设置时间到文件/tmp/log/user.log时logging上面的命令。
在我的Linux发行版中,日志logging由syslog-ng 。 我已经有一些日志进入/tmp/log/user.log 。
这是我系统中/etc/syslog-ng/syslog-ng.conf的内容,用于login到/tmp/log/user.log
destination d_notice { file("/tmp/log/user.log");}; filter f_filter10 { level(notice) and not facility(mail,authpriv,cron); }; log { source(s_sys); filter(f_filter10); destination(d_notice); };
我应该怎么做,以便date -s命令也login到/tmp/log/user.log
date更改不会被logging在默认情况下,至less不会在Debian上。
最简单的select是用一个封装器replace/ bin / date,它使用logger打印日志消息,然后调用真正的/ bin / date可执行文件,例如
mv /bin/date /bin/date.real cat << 'EOF' >/bin/date #!/bin/bash logger -p user.notice "date run by $UID: $*" /bin/date.real EOF chmod +x /bin/date
除此之外,我知道grsecurity允许您logging对系统时间的任何更改。 这将需要编译一个自定义的内核。