2017-11-08 4 views
0

linuxのいくつかの重要なファイル(nginx.confなど)の変更履歴をチェックしたいと思います。どのように特定のファイルの具体的な変更を記録するには?いつどのようなファイルが変更されるかのような変更。特定のファイルの具体的な変更を記録する方法

+1

Linuxのみ 'mtime'、ファイルの更新時刻を提供するスクリプトを見つけることができます。ファイルの*履歴*を追跡するには、設定マネージャやgitのようなものを使用します。 –

答えて

0

@ Jonathonのコメントに触発されて、すべての変更履歴を保持しながら、特定のファイルに対して行われたすべての変更を監視するシェルスクリプトを作成しました。スクリプトはインストールされているinotifywaitとgitパッケージに依存します。

現在地 https://github.com/hisham-hassan/linux-file-monitor

Usage: file-monitor.sh [-f|--file] <absolute-file-path> [-m|--monitor|-h|--history] 
     file-monitor.sh --help 

-f,--file <absolute-file-path> Adding a file to the monitored files List. The <absolute-file-path> 
           is the absolute file path of the file we need to action. 
           PLEASE NOTE: Relative file path could cause issues in the script, 
           please make sure to use the abolute path of the file. also try to 
           avoid sym links, as it has not been tested. 
           example: file-monitor.sh -f /absolute/path/to/file/test.txt -m 
-m, --monitor     Monitoring all the changes on the file. the monitoring will keep 
           happening as long as the script is running; you may need to run it 
           in the background. 
           example: file-monitor.sh -f /absolute/path/to/file/test.txt -m 
-h, --history     showing the full history of the file. 
           To exit, press "q" 
           example: file-monitor.sh -f /absolute/path/to/file/test.txt -h 
--uninstall     uninstalls the script from the bin direcotry, 
           and removes the monitoring history. 
--install      Adds the script to the bin directory, and creates 
           the directories and files needed for monitoring. 
--help       Prints this help message. 
関連する問題