"date -s" 명령 기록

"date -s" 명령 기록

나는 date -s <STRING>명령이 문자열에 설명된 시간을 설정한다는 것을 알고 있습니다 STRING.

내가 원하는 것은 파일에 시간을 설정하는 데 사용될 때마다 위 명령을 기록하는 것입니다 /tmp/log/user.log.

내 Linux 배포판에서 로깅은 syslog-ng. 이미 에 들어가는 로그가 있습니다 /tmp/log/user.log.

이것은 내 시스템에 로그인하기 위한 /etc/syslog-ng/syslog-ng.conf의 내용입니다./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명령도 로그인되도록 하려면 어떻게 해야 합니까?/tmp/log/user.log

답변1

날짜 변경 사항은 기본적으로 기록되지 않습니다. 적어도 Debian에서는 기록되지 않습니다.

logger가장 간단한 옵션은 /bin/date를 실제 /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

그 외에는 알고 있어요보안시스템 시간에 대한 변경 사항을 기록할 수 있습니다. 사용자 정의 커널을 컴파일해야 합니다.

관련 정보