{"id":908,"date":"2013-11-19T22:04:03","date_gmt":"2013-11-19T13:04:03","guid":{"rendered":"http:\/\/43.203.250.216\/?p=908"},"modified":"2020-12-30T17:10:10","modified_gmt":"2020-12-30T08:10:10","slug":"repo%ec%99%80-opengrok-update%eb%a5%bc-%ec%9c%84%ed%95%9c-cron%ec%9a%a9-script","status":"publish","type":"post","link":"https:\/\/litcoder.com\/?p=908","title":{"rendered":"Repo\uc640 OpenGrok update\ub97c \uc704\ud55c cron\uc6a9 script"},"content":{"rendered":"\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>OpenGrok\uc740 \uc5ec\ub7ec\uba74\uc5d0\uc11c \uc88b\uc740 \uc810\uc774 \ub9ce\uc740 \ub3c4\uad6c\uc774\uc9c0\ub9cc source code\uac00 \ubcc0\uacbd\ub420 \ub54c\ub9c8\ub2e4 \uc624\ub79c\uc2dc\uac04\uc774 \uac78\ub9ac\ub294 indexing\uc744 \ud574\uc57c \ud55c\ub2e4\ub294 \uc810\uc740 \ubd88\ud3b8 \ud55c \uc810 \uc911 \ud558\ub098\uc774\ub2e4. \uc5ec\uae30\uc11c\ub294 cron\uc73c\ub85c \ub3cc\ub9b4 \uc218 \uc788\ub294 \uac04\ub2e8\ud55c shell script\ub97c \uc0ac\uc6a9\ud574\uc11c \ud55c\uac00\ud55c \uc2dc\uac04\uc5d0 source\uac00 \ucd5c\uc2e0\uc73c\ub85c \uc720\uc9c0\ub420 \uc218 \uc788\ub3c4\ub85d \ud558\ub294 \ubc29\ubc95\uc744 \uc124\uba85\ud55c\ub2e4.<\/p><\/blockquote>\n\n\n\n<p><strong>Cron runnable update script<\/strong><\/p>\n\n\n\n<p>Cron\uc73c\ub85c \ub3d9\uc791\uc2dc\ud0a4\ub294 script\ub97c \uc791\uc131\ud560 \ub54c \uac00\uc7a5 \ub9ce\uc774 \uc2e4\uc218\ud558\ub294 \uac83\uc740 \ud658\uacbd\ubcc0\uc218\ub4e4\uc744 \uc0ac\uc6a9\ud560 \uc218 \uc5c6\ub2e4\ub294 \uac83\uc744 \uc885\uc885 \uc78a\ub294\ub2e4\ub294 \uc810\uc774\ub2e4. \uc774 script \uc5ed\uc2dc cron\uc5d0\uc11c \ub3d9\uc791\uc2dc\ud0ac \uac83\uc744 \uac10\uc548\ud574\uc11c \uc808\ub300 \uacbd\ub85c\ub97c \uc0ac\uc6a9\ud558\ub3c4\ub85d \uc791\uc131\ub418\uc5b4\uc57c \ud55c\ub2e4.<\/p>\n\n\n\n<p>\uc774 script\ub294 REPO_DIR_ROOT\ub85c \uc120\uc5b8\ud55c directory\uc5d0 \uc788\ub294 directory\ub4e4\uc744 \ub3cc\uc544\ub2e4\ub2c8\uba74\uc11c repo sync\ub97c \uc218\ud589\ud55c \ub2e4\uc74c OpenGrok index\ub97c \ub3cc\ub9ac\ub294 \uc77c\uc744 \ud55c\ub2e4. \ub2e4\uc74c \uc138\uac1c\uc758 \ubcc0\uc218\ub97c \uc790\uc2e0\uc5d0 \ub9de\uac8c \ubcc0\uacbd\ud574 \uc8fc\uc790.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>REPO_DIR_ROOT: Source repository\ub4e4\uc758 \ucd5c\uc0c1\uc704 directory<\/li><li>OPENGROK_DIR: OpenGrok binary\uc758 \uc704\uce58<\/li><li>REPO: Repo script\uc758 \uc704\uce58<\/li><\/ul>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"eclipse\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"true\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#!\/bin\/bash\n#\n# Cron runnable OpenGrok updating script.\n# This script syncs all source repositories under \n#  the REPO_DIR_ROOT then runs OpenGrok indexing. \n#\n#                                      -litcoder\n\n####\n# Configuration variables. - Use absolute path.\n#\n# * REPO_DIR_ROOT : Top of the source repositories\n# * OPENGROK_DIR : Path to OpenGrok executable\n# * REPO : Path to repo script\nREPO_DIR_ROOT=\"\/var\/opengrok\/src\"\nOPENGROK_DIR=\"\/var\/opengrok\/bin\/OpenGrok\"\nREPO=\"\/home\/&lt;&lt;YOUR_HOME_DIR>>\/bin\/repo\"\n####\n\nsync_cmd=\"$REPO sync\"\nrepodirs=`ls ${REPO_DIR_ROOT}`\n\n#################\nfunction clear_all_modifications\n{\n  #Make a master branch\n#  MASTER_BRANCH=\"master\"\n#  echo \"$REPO start $MASTER_BRANCH --all\"\n\n  #Clear all\n  echo \"$REPO forall -c 'git checkout -f&amp;&amp;git clean -f -d .\/'\"\n}\n\nfunction print_msg\n{\n  msg=$1\n  echo \"$msg\"\n}\n\nfunction print_msg_with_time\n{\n  msg=$1\n  echo \"$msg - [`date`]\"\n}\n\nfunction run_repo_sync\n{\n  repo_prj=$1\n  dirs_skip=$2\n  print_msg_with_time \"Syncing [$repo_prj]\"\n  cd ${REPO_DIR_ROOT}\/$repodir\/\n\n  print_msg \"Clear modifications\"\n  clear_all_modifications\n\n  $sync_cmd 2>&amp;1\n}\n\nfunction run_opengrok_index\n{\n  $OPENGROK_DIR index\n}\n\n#################\n\n#RepoSync \nprint_msg \"start syncing\"\n\nfor repodir in $repodirs\ndo\n  run_repo_sync $repodir\ndone\necho \"syncing has done at `date`\"\n\n#OpenGrok\nprint_msg_with_time \"Start OpenGrok indexing (`date`)\"\nrun_opengrok_index\n\necho \"done at `date`\"<\/pre>\n\n\n\n<p><strong>Cron Job \ub4f1\ub85d<\/strong><\/p>\n\n\n\n<p><a href=\"http:\/\/en.wikipedia.org\/wiki\/Cron\">Cron\uc744 \uc124\uc815\ud558\ub294 \ubc29\ubc95\uc5d0 \ub300\ud574 \uc798 \uc124\uba85\ub41c \ubb38\uc11c<\/a>\ub4e4\uc774 \ub9ce\uc73c\ub2c8 \uc774\uac83\uc744 \ucc38\uace0\ud574\uc11c crontab\uc744 \uc2e4\ud589\ud558\uace0 \uc2dc\uac04\uc744 \uc124\uc815\ud55c\ub2e4.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted lang:default highlight:0 decode:true\">$> crontab -e<\/pre>\n\n\n\n<p>\ub2e4\uc74c\uc740 \uae08\uc694\uc77c \uc624\ud6c4 7\uc2dc \ubd80\ud130 script\ub97c \uc2e4\ud589\ud558\uace0 home directory\uc5d0 <em>&#8216;opengrok_sync_log.txt&#8217;<\/em>&nbsp; file\uc5d0 \uc218\ud589 log\ub97c \ub0a8\uae30\ub3c4\ub85d \uc124\uc815\ud558\ub294 \uc608\uc774\ub2e4. \/home\/&lt;your_home_dir&gt;\/bin \uc544\ub798\uc5d0 update_opengrok.sh\ub77c\ub294 \uc774\ub984\uc73c\ub85c script\ub97c \uc800\uc7a5\ud55c\ub2e4\uace0 \uac00\uc815\ud588\ub2e4.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"eclipse\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># Edit this file to introduce tasks to be run by cron.\n# \n# Each task to run has to be defined through a single line\n# indicating with different fields when the task will be run\n# and what command to run for the task\n# \n# To define the time you can provide concrete values for\n# minute (m), hour (h), day of month (dom), month (mon),\n# and day of week (dow) or use '*' in these fields (for 'any').# \n# Notice that tasks will be started based on the cron's system\n# daemon's notion of time and timezones.\n# \n# Output of the crontab jobs (including errors) is sent through\n# email to the user the crontab file belongs to (unless redirected).\n# \n# For example, you can run a backup of all your user accounts\n# at 5 a.m every week with:\n# 0 5 * * 1 tar -zcf \/var\/backups\/home.tgz \/home\/\n# \n# For more information see the manual pages of crontab(5) and cron(8)\n# \n# m h  dom mon dow   command\n00 19 * * 5 \/home\/&lt;YOUR_HOME_DIR>\/bin\/update_opengrok.sh > \/home\/&lt;YOUR_HOME_DIR>\/opengrok_sync_log.txt<\/pre>\n\n\n\n<p><strong>\uc8fc\uc758\ud560 \uc810<\/strong><\/p>\n\n\n\n<p>Crontab \uc2e4\ud589\uc8fc\uae30\ub97c \uacb0\uc815\ud560 \ub54c script\uc758 \uc218\ud589\uc5d0 \uc18c\uc694\ub418\ub294 \uc2dc\uac04\uc744 \uace0\ub824\ud574\uc57c \ud55c\ub2e4. \ub108\ubb34 \uc7a6\uc740 \uc8fc\uae30\ub85c \uc124\uc815\ud574 \ub193\uc73c\uba74 \uc774\uc804\uc758 job\ub4e4\uc774 \ub05d\ub098\uc9c0 \uc54a\uc740 \uc0c1\ud0dc\uc5d0\uc11c \ub2e4\uc74c job\uc774 \uc2e4\ud589\ub418\ub294 \uacbd\uc6b0\uac00 \uc0dd\uae30\uac8c \ub418\uace0 \uc774\uac83\ub4e4\uc774 \uc313\uc5ec\uc11c system \uc790\uc6d0\uc744 \uc7a1\uc544\uba39\uace0 \ub290\ub824\uc9c0\ub2e4\uac00 \uacb0\uad6d\uc740 system \uad00\ub9ac\uc790\uc758 \uc804\ud654\ub97c \ubc1b\uac8c \ub420 \uc218\ub3c4 \uc788\ub2e4. \ud83d\ude09<\/p>\n","protected":false},"excerpt":{"rendered":"<p>OpenGrok\uc740 \uc5ec\ub7ec\uba74\uc5d0\uc11c \uc88b\uc740 \uc810\uc774 \ub9ce\uc740 \ub3c4\uad6c\uc774\uc9c0\ub9cc source code\uac00 \ubcc0\uacbd\ub420 \ub54c\ub9c8\ub2e4 \uc624\ub79c\uc2dc\uac04\uc774 \uac78\ub9ac\ub294 indexing\uc744 \ud574\uc57c \ud55c\ub2e4\ub294 \uc810\uc740 \ubd88\ud3b8 \ud55c \uc810 \uc911 \ud558\ub098\uc774\ub2e4. \uc5ec\uae30\uc11c\ub294 cron\uc73c\ub85c \ub3cc\ub9b4 \uc218 \uc788\ub294 \uac04\ub2e8\ud55c shell script\ub97c \uc0ac\uc6a9\ud574\uc11c \ud55c\uac00\ud55c \uc2dc\uac04\uc5d0 source\uac00 \ucd5c\uc2e0\uc73c\ub85c \uc720\uc9c0\ub420 \uc218 \uc788\ub3c4\ub85d \ud558\ub294 \ubc29\ubc95\uc744 \uc124\uba85\ud55c\ub2e4. Cron runnable update script Cron\uc73c\ub85c \ub3d9\uc791\uc2dc\ud0a4\ub294 script\ub97c \uc791\uc131\ud560 \ub54c \uac00\uc7a5 \ub9ce\uc774 \uc2e4\uc218\ud558\ub294 \uac83\uc740 \ud658\uacbd\ubcc0\uc218\ub4e4\uc744 \uc0ac\uc6a9\ud560 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[5],"tags":[20,29,90,111],"class_list":["post-908","post","type-post","status-publish","format-standard","hentry","category-programming","tag-bash","tag-cron","tag-opengrok","tag-script"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/litcoder.com\/index.php?rest_route=\/wp\/v2\/posts\/908","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/litcoder.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/litcoder.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/litcoder.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/litcoder.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=908"}],"version-history":[{"count":1,"href":"https:\/\/litcoder.com\/index.php?rest_route=\/wp\/v2\/posts\/908\/revisions"}],"predecessor-version":[{"id":2755,"href":"https:\/\/litcoder.com\/index.php?rest_route=\/wp\/v2\/posts\/908\/revisions\/2755"}],"wp:attachment":[{"href":"https:\/\/litcoder.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=908"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/litcoder.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=908"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/litcoder.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=908"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}