Shell 当x用户更改linux服务器上的z文件时发出警报

Shell 当x用户更改linux服务器上的z文件时发出警报,shell,Shell,实际上,我想跟踪在z文件中进行任何更改的用户,其中z文件被n个用户访问。我正在尝试使用上述脚本至少在z文件更改时获取警报。我不知道如何跟踪哪个用户更改了它。随附的inotifywait实用程序将帮助您在不轮询的情况下捕获事件: Alert when z file on linux server has been changed by x user. #/bin/sh old_time=`stat -c %z /var/spool/cron/root` if [[ "$new_time" !

实际上,我想跟踪在z文件中进行任何更改的用户,其中z文件被n个用户访问。我正在尝试使用上述脚本至少在z文件更改时获取警报。我不知道如何跟踪哪个用户更改了它。

随附的
inotifywait
实用程序将帮助您在不轮询的情况下捕获事件:

Alert when z file on linux server has been changed by x user.
#/bin/sh
old_time=`stat -c %z /var/spool/cron/root` 
  if [[ "$new_time" != "$old_time" ]]; 
    then 
      echo -e "Changes has been made in Cron file" | mail -s "Modification alert" abhinav.dixit@xyz.com 
    echo -e "$old_time" 
    echo -e "$new_time" 
  else 
    echo "no change" 
 fi 


建议使用审核守护程序按用户跟踪文件修改。

随附的
inotifywait
实用程序将帮助您捕获事件,而无需轮询:

Alert when z file on linux server has been changed by x user.
#/bin/sh
old_time=`stat -c %z /var/spool/cron/root` 
  if [[ "$new_time" != "$old_time" ]]; 
    then 
      echo -e "Changes has been made in Cron file" | mail -s "Modification alert" abhinav.dixit@xyz.com 
    echo -e "$old_time" 
    echo -e "$new_time" 
  else 
    echo "no change" 
 fi 

建议使用审核守护进程跟踪用户对文件的修改