{"id":1003652,"date":"2020-09-10T15:26:16","date_gmt":"2020-09-10T22:26:16","guid":{"rendered":"https:\/\/www.esri.com\/arcgis-blog\/?post_type=blog&#038;p=1003652"},"modified":"2020-09-10T15:26:16","modified_gmt":"2020-09-10T22:26:16","slug":"monthly-linux-tip-bash-cron-arcgis-server-oh-my","status":"publish","type":"blog","link":"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-enterprise\/administration\/monthly-linux-tip-bash-cron-arcgis-server-oh-my","title":{"rendered":"Monthly Linux Tip: Bash, Cron, ArcGIS Server, Oh My!"},"author":10252,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","format":"standard","meta":{"_acf_changed":false,"_searchwp_excluded":""},"categories":[37501],"tags":[],"industry":[],"product":[36571],"class_list":["post-1003652","blog","type-blog","status-publish","format-standard","hentry","category-administration","product-arcgis-enterprise"],"acf":{"short_description":"This blog discusses automation with Linux utilities Bash and Cron with ArcGIS Server.","flexible_content":[{"acf_fc_layout":"content","content":"<p><em>NOTE: This Monthly Linux Tip discusses using bash and cron, more advanced Linux administrative topics. Both topics will be briefly discussed, but not explained in great depth as that falls outside the scope of this blog.<\/em><\/p>\n<p>It is no secret that some tasks are more repetitive than others; this is especially true with daily administrative tasks. To handle such repetition, automation is often the answer. ArcGIS Enterprise offers several built-in tools to promote automation in repetitive workflows, such as creating an ArcGIS Server site for multiple machines. In this Monthly Linux Tip, we will explore using Linux utilities bash and cron to automate creating an ArcGIS Server site. Listed below is the table of contents we will follow:<\/p>\n<ol>\n<li>Why Bash?<\/li>\n<li>Using Bash with ArcGIS Server<\/li>\n<li>Combining Bash and ArcGIS Server into Cron<\/li>\n<\/ol>\n<p><strong>1. Why Bash<\/strong>?<\/p>\n<p>Shell scripting is arguably one of the most important tools that comes pre-built with every Linux distribution. Shell scripting is so powerful because every command that can be executed in the terminal can be automated. There are several shells such as Bourne shell (<em>sh<\/em>), Z shell (<em>zsh<\/em>), korn shell (<em>ksh<\/em>) and the list goes on.<\/p>\n<p>Most popularly used in Linux is Bash (<em>Bourne Again Shell<\/em>). As bash is most commonly used in Linux distributions, we will focus on this shell in today\u2019s tip.<\/p>\n<p><strong>2. Using Bash with ArcGIS Server<\/strong><\/p>\n<p>Previously mentioned, ArcGIS Server comes with several tools that promotes utilizing automation. Let\u2019s explore the following user story:<\/p>\n<p>\u201c<em>My name is Joe and I am the system administrator for my organization. A common practice for us is to stand up several QA and development machines with ArcGIS Server installed before going into production. These environments typically last for around 3 months before they\u2019re destroyed. Is there a way to automate ArcGIS Server installations so that I don\u2019t have to manually do this process every time?\u201d<\/em><\/p>\n<p>In the above user story, Bash would be a great choice to get up and going with automated ArcGIS Server installations. Below, here is a simplified Bash script named <em>createAGS.sh<\/em> that Joe might use:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"\" src=\"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/09\/sample-script.png\" width=\"988\" height=\"352\" \/><\/p>\n<p>In a realistic scenario, this script will be more comprehensive and not make assumptions about the system (as well as a better username and password). Looking past that, we see that the <em>install_server<\/em> function is calling upon the <em>Setup<\/em> script to install. Similarly, we see that the <em>configure_server<\/em> function utilizes the <em>createsite.sh<\/em> script to create the ArcGIS Server site.<\/p>\n<p>This bash script by itself can be used throughout each of Joe\u2019s QA and development machines and eliminates manual effort. However, to take it a step further, Joe can additionally utilize cron scheduling to fully automate.<\/p>\n<p><strong>3. Combining Bash, ArcGIS Server and Cron<\/strong><\/p>\n<p>It is nearing the end of the three-month interval Joe earlier described and he is creating a new set of machines. Despite the <em>createAGS.sh <\/em>script\u00a0he has, Joe wants a way to have this entire process fully automated after he creates the machines. This is where <em>crontab<\/em> will come in handy.<\/p>\n<p>Crontab (CRON TABle) is a virtualized table in the system that can schedule repetitive tasks. System administrators mostly use this for system backups, updates, file synchronization, etc. The syntax of cron jobs are as follows:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"\" src=\"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/09\/cron-syntax.png\" width=\"644\" height=\"362\" \/><\/p>\n<p>In Joe\u2019s case, we will create a crontab that takes advantage of the <em>createAGS.sh<\/em> script so that every 3 months, this script will run. To do this, Joe will use the command <em>crontab -e<\/em> to create a new cron job as the ArcGIS Server installation user. Below is an example of the <em>createAGS.sh<\/em> script running at 12PM on the 1<sup>st<\/sup> of January, April, July and October:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/09\/sample-cron-job.png\" \/><\/p>\n<p>Realistically, the three-month interval will depend on when Joe creates the environments, but the overall syntax would look the same.<\/p>\n<p><strong>Conclusion<\/strong><\/p>\n<p>In this Monthly Linux tip, we went over utilizing built in Linux tools Bash and cron and how they can help automate ArcGIS Enterprise. There are several automation utilities available, so please explore what works best for your organization.<\/p>\n<p>Please feel free to leave a comment on this blog and what you would like to see next month. Thanks for reading this Monthly Linux Tip!<\/p>\n"}],"authors":[{"ID":10252,"user_firstname":"Markus","user_lastname":"Walker","nickname":"MWalker","user_nicename":"mwalker","display_name":"Markus Walker","user_email":"MWalker@esri.com","user_url":"","user_registered":"2019-12-03 14:04:26","user_description":"Markus is a Product Engineer on the ArcGIS Enterprise team, where he specializes with Linux architectures.","user_avatar":"<img data-del=\"avatar\" src='https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2021\/04\/31161cb9-c3aa-493e-8ff2-5b3a3ff46361-213x200.jpg' class='avatar pp-user-avatar avatar-96 photo ' height='96' width='96'\/>"}],"related_articles":"","card_image":false,"wide_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2019\/09\/1071enterprisebanner.png"},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.9 (Yoast SEO v25.9) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Monthly Linux Tip: Bash, Cron, ArcGIS Server, Oh My!<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-enterprise\/administration\/monthly-linux-tip-bash-cron-arcgis-server-oh-my\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Monthly Linux Tip: Bash, Cron, ArcGIS Server, Oh My!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-enterprise\/administration\/monthly-linux-tip-bash-cron-arcgis-server-oh-my\" \/>\n<meta property=\"og:site_name\" content=\"ArcGIS Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/esrigis\/\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@ESRI\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":[\"Article\",\"BlogPosting\"],\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-enterprise\/administration\/monthly-linux-tip-bash-cron-arcgis-server-oh-my#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-enterprise\/administration\/monthly-linux-tip-bash-cron-arcgis-server-oh-my\"},\"author\":{\"name\":\"Markus Walker\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/person\/457f3d786c7c12c3d37d57b3d6f2702f\"},\"headline\":\"Monthly Linux Tip: Bash, Cron, ArcGIS Server, Oh My!\",\"datePublished\":\"2020-09-10T22:26:16+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-enterprise\/administration\/monthly-linux-tip-bash-cron-arcgis-server-oh-my\"},\"wordCount\":9,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#organization\"},\"articleSection\":[\"Administration\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-enterprise\/administration\/monthly-linux-tip-bash-cron-arcgis-server-oh-my#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-enterprise\/administration\/monthly-linux-tip-bash-cron-arcgis-server-oh-my\",\"url\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-enterprise\/administration\/monthly-linux-tip-bash-cron-arcgis-server-oh-my\",\"name\":\"Monthly Linux Tip: Bash, Cron, ArcGIS Server, Oh My!\",\"isPartOf\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#website\"},\"datePublished\":\"2020-09-10T22:26:16+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-enterprise\/administration\/monthly-linux-tip-bash-cron-arcgis-server-oh-my#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-enterprise\/administration\/monthly-linux-tip-bash-cron-arcgis-server-oh-my\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-enterprise\/administration\/monthly-linux-tip-bash-cron-arcgis-server-oh-my#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.esri.com\/arcgis-blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Monthly Linux Tip: Bash, Cron, ArcGIS Server, Oh My!\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#website\",\"url\":\"https:\/\/www.esri.com\/arcgis-blog\/\",\"name\":\"ArcGIS Blog\",\"description\":\"Get insider info from Esri product teams\",\"publisher\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.esri.com\/arcgis-blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#organization\",\"name\":\"Esri\",\"url\":\"https:\/\/www.esri.com\/arcgis-blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2018\/04\/Esri.png\",\"contentUrl\":\"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2018\/04\/Esri.png\",\"width\":400,\"height\":400,\"caption\":\"Esri\"},\"image\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/esrigis\/\",\"https:\/\/x.com\/ESRI\",\"https:\/\/www.linkedin.com\/company\/5311\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/person\/457f3d786c7c12c3d37d57b3d6f2702f\",\"name\":\"Markus Walker\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2021\/04\/31161cb9-c3aa-493e-8ff2-5b3a3ff46361-213x200.jpg\",\"contentUrl\":\"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2021\/04\/31161cb9-c3aa-493e-8ff2-5b3a3ff46361-213x200.jpg\",\"caption\":\"Markus Walker\"},\"description\":\"Markus is a Product Engineer on the ArcGIS Enterprise team, where he specializes with Linux architectures.\",\"url\":\"https:\/\/www.esri.com\/arcgis-blog\/author\/mwalker\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Monthly Linux Tip: Bash, Cron, ArcGIS Server, Oh My!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-enterprise\/administration\/monthly-linux-tip-bash-cron-arcgis-server-oh-my","og_locale":"en_US","og_type":"article","og_title":"Monthly Linux Tip: Bash, Cron, ArcGIS Server, Oh My!","og_url":"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-enterprise\/administration\/monthly-linux-tip-bash-cron-arcgis-server-oh-my","og_site_name":"ArcGIS Blog","article_publisher":"https:\/\/www.facebook.com\/esrigis\/","twitter_card":"summary_large_image","twitter_site":"@ESRI","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":["Article","BlogPosting"],"@id":"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-enterprise\/administration\/monthly-linux-tip-bash-cron-arcgis-server-oh-my#article","isPartOf":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-enterprise\/administration\/monthly-linux-tip-bash-cron-arcgis-server-oh-my"},"author":{"name":"Markus Walker","@id":"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/person\/457f3d786c7c12c3d37d57b3d6f2702f"},"headline":"Monthly Linux Tip: Bash, Cron, ArcGIS Server, Oh My!","datePublished":"2020-09-10T22:26:16+00:00","mainEntityOfPage":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-enterprise\/administration\/monthly-linux-tip-bash-cron-arcgis-server-oh-my"},"wordCount":9,"commentCount":0,"publisher":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/#organization"},"articleSection":["Administration"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-enterprise\/administration\/monthly-linux-tip-bash-cron-arcgis-server-oh-my#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-enterprise\/administration\/monthly-linux-tip-bash-cron-arcgis-server-oh-my","url":"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-enterprise\/administration\/monthly-linux-tip-bash-cron-arcgis-server-oh-my","name":"Monthly Linux Tip: Bash, Cron, ArcGIS Server, Oh My!","isPartOf":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/#website"},"datePublished":"2020-09-10T22:26:16+00:00","breadcrumb":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-enterprise\/administration\/monthly-linux-tip-bash-cron-arcgis-server-oh-my#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-enterprise\/administration\/monthly-linux-tip-bash-cron-arcgis-server-oh-my"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-enterprise\/administration\/monthly-linux-tip-bash-cron-arcgis-server-oh-my#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.esri.com\/arcgis-blog\/"},{"@type":"ListItem","position":2,"name":"Monthly Linux Tip: Bash, Cron, ArcGIS Server, Oh My!"}]},{"@type":"WebSite","@id":"https:\/\/www.esri.com\/arcgis-blog\/#website","url":"https:\/\/www.esri.com\/arcgis-blog\/","name":"ArcGIS Blog","description":"Get insider info from Esri product teams","publisher":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.esri.com\/arcgis-blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.esri.com\/arcgis-blog\/#organization","name":"Esri","url":"https:\/\/www.esri.com\/arcgis-blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2018\/04\/Esri.png","contentUrl":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2018\/04\/Esri.png","width":400,"height":400,"caption":"Esri"},"image":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/esrigis\/","https:\/\/x.com\/ESRI","https:\/\/www.linkedin.com\/company\/5311\/"]},{"@type":"Person","@id":"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/person\/457f3d786c7c12c3d37d57b3d6f2702f","name":"Markus Walker","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/person\/image\/","url":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2021\/04\/31161cb9-c3aa-493e-8ff2-5b3a3ff46361-213x200.jpg","contentUrl":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2021\/04\/31161cb9-c3aa-493e-8ff2-5b3a3ff46361-213x200.jpg","caption":"Markus Walker"},"description":"Markus is a Product Engineer on the ArcGIS Enterprise team, where he specializes with Linux architectures.","url":"https:\/\/www.esri.com\/arcgis-blog\/author\/mwalker"}]}},"text_date":"September 10, 2020","author_name":"Markus Walker","author_page":"https:\/\/www.esri.com\/arcgis-blog\/author\/mwalker","custom_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2019\/09\/1071enterprisebanner.png","primary_product":"ArcGIS Enterprise","tag_data":[],"category_data":[{"term_id":37501,"name":"Administration","slug":"administration","term_group":0,"term_taxonomy_id":37501,"taxonomy":"category","description":"","parent":0,"count":427,"filter":"raw"}],"product_data":[{"term_id":36571,"name":"ArcGIS Enterprise","slug":"arcgis-enterprise","term_group":0,"term_taxonomy_id":36571,"taxonomy":"product","description":"","parent":0,"count":977,"filter":"raw"}],"primary_product_link":"https:\/\/www.esri.com\/arcgis-blog\/?s=#&products=arcgis-enterprise","_links":{"self":[{"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/blog\/1003652","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/blog"}],"about":[{"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/types\/blog"}],"author":[{"embeddable":true,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/users\/10252"}],"replies":[{"embeddable":true,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/comments?post=1003652"}],"version-history":[{"count":0,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/blog\/1003652\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/media?parent=1003652"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/categories?post=1003652"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/tags?post=1003652"},{"taxonomy":"industry","embeddable":true,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/industry?post=1003652"},{"taxonomy":"product","embeddable":true,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/product?post=1003652"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}