{"id":3870,"date":"2016-06-30T22:27:30","date_gmt":"2016-06-30T20:27:30","guid":{"rendered":"http:\/\/michlstechblog.info\/blog\/?p=3870"},"modified":"2016-07-12T11:43:14","modified_gmt":"2016-07-12T09:43:14","slug":"linux-track-changes-of-a-folder-by-git-and-cron","status":"publish","type":"post","link":"https:\/\/michlstechblog.info\/blog\/linux-track-changes-of-a-folder-by-git-and-cron\/","title":{"rendered":"Linux: Track changes of a folder by git and cron"},"content":{"rendered":"<div class=\"twoclick_social_bookmarks_post_3870 social_share_privacy clearfix 1.6.4 locale-en_US sprite-en_US\"><\/div><div class=\"twoclick-js\"><script type=\"text\/javascript\">\/* <![CDATA[ *\/\njQuery(document).ready(function($){if($('.twoclick_social_bookmarks_post_3870')){$('.twoclick_social_bookmarks_post_3870').socialSharePrivacy({\"services\":{\"flattr\":{\"uid\":\"Michl\",\"status\":\"on\",\"the_title\":\"Linux%3A%20Track%20changes%20of%20a%20folder%20by%20git%20and%20cron\",\"the_excerpt\":\"Hi%2C%0D%0A%0D%0Athis%20post%20describes%20howto%20to%20track%20changes%20to%20a%20folder%20with%20some%20%28text%29%20files%20in%20it.%0D%0A%20%28more%26hellip%3B%29\",\"txt_info\":\"2 clicks for more data protection:\\r\\n\\r\\nOnly when you click here, the button will be come active and you can send your recommendation to Flattr. When activating, data are transmitted to third parties. \",\"perma_option\":\"off\"}},\"txt_help\":\"When you activate these fields by clicking, information to Flattr may be transferred abroad, and probably may also stored there.\",\"settings_perma\":\"Enable permanently and accept data transmission. \",\"info_link\":\"http:\\\/\\\/www.heise.de\\\/ct\\\/artikel\\\/2-Klicks-fuer-mehr-Datenschutz-1333879.html\",\"uri\":\"https:\\\/\\\/michlstechblog.info\\\/blog\\\/linux-track-changes-of-a-folder-by-git-and-cron\\\/\",\"post_id\":3870,\"post_title_referrer_track\":\"Linux%3A+Track+changes+of+a+folder+by+git+and+cron\",\"display_infobox\":\"on\"});}});\n\/* ]]> *\/<\/script><\/div><p>Hi,<\/p>\n<p>this post describes howto to track changes to a folder with some (text) files in it.<br \/>\n<!--more--><br \/>\nLet use assume we want to track the zone files of a bind name server daemon. <\/p>\n<ul>\n<li>The files are located in \/var\/named<\/li>\n<li>The track frequency is 3h<\/li>\n<\/ul>\n<p>Install necessary packages (here for debian\/Ubuntu\/Mint), gitk is just needed if you want to use a X11 GUI for compare changes<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nroot@debdev # apt-get update\r\nroot@debdev # apt-get -y install git gitk\r\n<\/pre>\n<p>First we have to create a git repository, add all files and make a first commit. For security reasons use the named user.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nroot@debdev # cd \/var\/named\r\nroot@debdev # git init\r\nroot@debdev # chown -R named:named \/var\/named\/.git\r\n<\/pre>\n<p>Change User<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nroot@debdev # su named -s \/bin\/bash\r\nbash-4.1 $  git add --all\r\nbash-4.1 $  git commit -m &quot;DNS repository init.&quot;\r\n<\/pre>\n<p>Create a cron job. The job is running every 3 hours and creates a git tag when changes are detected.<br \/>\nOpen crontab<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nbash-4.1 $  crontab -e\r\n<\/pre>\n<p>and add the job.<br \/>\n<code><br \/>\n# Git Job for tracking bind zone files<br \/>\n0 *\/3 * * * (cd \/var\/named &&  git add --all && git commit -a -m \" `date`\" && git tag -a `date +\\%Y\\%m\\%d-\\%H\\%M` -m `date +\\%Y\\%m\\%d-\\%H\\%M`)<br \/>\n<\/code><\/p>\n<p>Michael<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi, this post describes howto to track changes to a folder with some (text) files in it.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[805,3],"tags":[873,875,45,874,876,505,872],"class_list":["post-3870","post","type-post","status-publish","format-standard","hentry","category-git","category-linux","tag-changes","tag-cron","tag-directory","tag-folder","tag-frequently","tag-git","tag-track"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/3870","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/comments?post=3870"}],"version-history":[{"count":9,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/3870\/revisions"}],"predecessor-version":[{"id":3913,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/3870\/revisions\/3913"}],"wp:attachment":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/media?parent=3870"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/categories?post=3870"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/tags?post=3870"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}