{"id":680,"date":"2022-09-12T14:29:05","date_gmt":"2022-09-12T12:29:05","guid":{"rendered":"http:\/\/cln.io\/blog\/?p=680"},"modified":"2023-03-18T15:25:44","modified_gmt":"2023-03-18T13:25:44","slug":"adding-cronjobs-to-udm","status":"publish","type":"post","link":"https:\/\/cln.io\/blog\/adding-cronjobs-to-udm\/","title":{"rendered":"Adding cron jobs to the UDM Pro (  Dream Machine Pro )"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">The UDM Pro isn&#8217;t so &#8220;pro&#8221; since there are some essential features missing from the UI interface (eg: SNAT \/ DNAT ) nonetheless we can &#8220;hack&#8221; our way into getting what we want -ish.<br><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">There is a fantastic project\/effort on GitHub to allow users to run scripts on the boot of the UDM Pro, we will use this to our advantage!<br><a href=\"https:\/\/github.com\/unifi-utilities\/unifios-utilities\" target=\"_blank\" rel=\"noreferrer noopener\">unifi-utilities\/unifios-utilities<\/a> <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"> We are particularly interested in the <a href=\"https:\/\/github.com\/unifi-utilities\/unifios-utilities\/tree\/main\/on-boot-script\" target=\"_blank\" rel=\"noreferrer noopener\">on-boot-script<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">On this page<\/p>\n\n\n\n<nav aria-label=\"Table of Contents\" class=\"wp-block-table-of-contents\"><ol><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/cln.io\/blog\/adding-cronjobs-to-udm\/#installing-on-boot-script-on-the-udm-pro\">Installing on-boot-script on the UDM-Pro<\/a><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/cln.io\/blog\/adding-cronjobs-to-udm\/#ssh-access-to-the-udm\">SSH access to the UDM<\/a><ol><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/cln.io\/blog\/adding-cronjobs-to-udm\/#ssh-ing-using-the-debug-interface\">SSH&#8217;ing using the debug interface<\/a><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/cln.io\/blog\/adding-cronjobs-to-udm\/#ssh-using-a-direct-connection\">SSH using a direct connection<\/a><\/li><\/ol><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/cln.io\/blog\/adding-cronjobs-to-udm\/#adding-the-cron-job-boot-script\">Adding the cron job boot script<\/a><\/li><\/ol><\/nav>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"installing-on-boot-script-on-the-udm-pro\">Installing on-boot-script on the UDM-Pro<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/cln.io\/blog\/installing-on-boot-script-on-an-udm\/\" target=\"_blank\" rel=\"noreferrer noopener\">First, we need on-boot-script installed on the UDM, check out how to do this in my guide over here<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"ssh-access-to-the-udm\">SSH access to the UDM<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">there are two ways to get SSH access, enabling it and SSH&#8217;ing into the box, or using the debug option from the Unifi manage interface<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"ssh-ing-using-the-debug-interface\">SSH&#8217;ing using the debug interface<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">head over to your Unifi network interface and go to &#8220;unifi devices&#8221;<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"768\" height=\"494\" src=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/03\/Screenshot-2023-03-18-at-14.06.00.png\" alt=\"\" class=\"wp-image-1399\" srcset=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/03\/Screenshot-2023-03-18-at-14.06.00.png 768w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/03\/Screenshot-2023-03-18-at-14.06.00-300x193.png 300w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">Locate your UDM and click on it, go to settings and in the bottom open the &#8220;Manage&#8221; tab and click on debug<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"655\" height=\"1024\" src=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/03\/Screenshot-2023-03-18-at-14.03.41-655x1024.png\" alt=\"\" class=\"wp-image-1398\" srcset=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/03\/Screenshot-2023-03-18-at-14.03.41-655x1024.png 655w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/03\/Screenshot-2023-03-18-at-14.03.41-192x300.png 192w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/03\/Screenshot-2023-03-18-at-14.03.41-768x1201.png 768w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/03\/Screenshot-2023-03-18-at-14.03.41.png 802w\" sizes=\"auto, (max-width: 655px) 100vw, 655px\" \/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">this will open a live SSH session to your UDM<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"ssh-using-a-direct-connection\">SSH using a direct connection<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">you can directly SSH into the UDM with the credentials configured under &#8220;<a rel=\"noreferrer noopener\" href=\"https:\/\/unifi.ui.com\/\" target=\"_blank\">Console Settings<\/a>&#8221; <\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"281\" height=\"442\" src=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2022\/09\/image-42.png\" alt=\"\" class=\"wp-image-721\" srcset=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2022\/09\/image-42.png 281w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2022\/09\/image-42-191x300.png 191w\" sizes=\"auto, (max-width: 281px) 100vw, 281px\" \/><figcaption class=\"wp-element-caption\">set an SSH password (username is root)<\/figcaption><\/figure>\n<\/div>\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"839\" height=\"533\" src=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2022\/09\/image-39.png\" alt=\"\" class=\"wp-image-707\" srcset=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2022\/09\/image-39.png 839w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2022\/09\/image-39-300x191.png 300w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2022\/09\/image-39-768x488.png 768w\" sizes=\"auto, (max-width: 839px) 100vw, 839px\" \/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"adding-the-cron-job-boot-script\">Adding the cron job boot script<\/h2>\n\n\n\n<p class=\"has-vivid-red-color has-text-color wp-block-paragraph\">NOTE: 04\/2023: the location has changed from \/mnt\/data to \/data, so screenshots are out of date<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s grab the cron script from the repo and add it to the on_boot.d folder<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"bash\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">cd \/data\/on_boot.d\/\ncurl https:\/\/raw.githubusercontent.com\/unifi-utilities\/unifios-utilities\/main\/on-boot-script\/examples\/udm-files\/on_boot.d\/25-add-cron-jobs.sh --output 25-add-cron-jobs.sh\nchmod +x 25-add-cron-jobs.sh<\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"249\" src=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2022\/09\/image-37-1024x249.png\" alt=\"\" class=\"wp-image-693\" srcset=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2022\/09\/image-37-1024x249.png 1024w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2022\/09\/image-37-300x73.png 300w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2022\/09\/image-37-768x187.png 768w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2022\/09\/image-37.png 1103w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">With this script being present, on boot, it will copy cronjobs from<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>\/data\/cronjobs\/<\/em> &#x27a1;&#xfe0f; to &#x27a1;&#xfe0f; <em>\/etc\/cron.d\/<\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you want a cron job, make sure to add it to <em>\/mnt\/data\/cronjobs\/<\/em> (be sure to add the folder first)<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"bash\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">mkdir \/data\/cronjobs\/<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Example of my UptimeRobot cron job (<a href=\"https:\/\/cln.io\/blog\/monitoring-an-udm-with-uptimerobot\/\" target=\"_blank\" rel=\"noreferrer noopener\">guide here<\/a>):<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"bash\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">cat \/data\/cronjobs\/uptimerobot\n* * * * * root curl -fsL \"https:\/\/heartbeat.uptimerobot.com\/xxx\" >\/dev\/null 2>&amp;1<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"683\" src=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2022\/09\/julia-taubitz-YonLTnjaR6o-unsplash-1024x683.jpg\" alt=\"\" class=\"wp-image-746\" srcset=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2022\/09\/julia-taubitz-YonLTnjaR6o-unsplash-1024x683.jpg 1024w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2022\/09\/julia-taubitz-YonLTnjaR6o-unsplash-300x200.jpg 300w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2022\/09\/julia-taubitz-YonLTnjaR6o-unsplash-768x512.jpg 768w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2022\/09\/julia-taubitz-YonLTnjaR6o-unsplash-1536x1024.jpg 1536w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2022\/09\/julia-taubitz-YonLTnjaR6o-unsplash-2048x1365.jpg 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Photo by <a href=\"https:\/\/unsplash.com\/@schwarzeweissheitenfotografie?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText\" target=\"_blank\" rel=\"noreferrer noopener\">Julia Taubitz<\/a> on <a href=\"https:\/\/unsplash.com\/s\/photos\/schedule?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText\" target=\"_blank\" rel=\"noreferrer noopener\">Unsplash<\/a><\/figcaption><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>The UDM Pro isn&#8217;t so &#8220;pro&#8221; since there are some essential features missing from the UI interface (eg: SNAT \/ DNAT ) nonetheless we can &#8220;hack&#8221; our way into getting what we want -ish. There [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":702,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26,37],"tags":[],"class_list":["post-680","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-it","category-networking"],"_links":{"self":[{"href":"https:\/\/cln.io\/blog\/wp-json\/wp\/v2\/posts\/680","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cln.io\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cln.io\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cln.io\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cln.io\/blog\/wp-json\/wp\/v2\/comments?post=680"}],"version-history":[{"count":30,"href":"https:\/\/cln.io\/blog\/wp-json\/wp\/v2\/posts\/680\/revisions"}],"predecessor-version":[{"id":1412,"href":"https:\/\/cln.io\/blog\/wp-json\/wp\/v2\/posts\/680\/revisions\/1412"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cln.io\/blog\/wp-json\/wp\/v2\/media\/702"}],"wp:attachment":[{"href":"https:\/\/cln.io\/blog\/wp-json\/wp\/v2\/media?parent=680"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cln.io\/blog\/wp-json\/wp\/v2\/categories?post=680"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cln.io\/blog\/wp-json\/wp\/v2\/tags?post=680"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}