{"id":1346,"date":"2021-02-18T10:42:44","date_gmt":"2021-02-18T14:42:44","guid":{"rendered":"https:\/\/io.bainwerx.com\/blog\/?p=1346"},"modified":"2021-02-18T10:43:09","modified_gmt":"2021-02-18T14:43:09","slug":"nvme-drive-keep-alive-script","status":"publish","type":"post","link":"https:\/\/io.bainwerx.com\/blog\/nvme-drive-keep-alive-script\/","title":{"rendered":"NVME Drive Keep Alive Script"},"content":{"rendered":"\n<p>Placed in \/Scripts\/keepalive<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"> pi@raspberry01:~\/Scripts\/keepalive$ cat keepalive.sh \n #bin\/bash\n \n## BAINWERX\n## NVME Keepalive Read|Write Script\n## version 1.2\n## created Feb 2021\n\n## Time in 12 hr format\n logging_time=$(date +'%r')\n \n## backup dir format\n logging_dir=$(date +'%m_%d_%Y')\n \nfind \/home\/pi\/Scripts\/keepalive\/*.log -mtime 1 -delete;\n echo \"NVME Keepalive Read|Write at\" \"${logging_time}\" >> \/home\/pi\/Scripts\/keepalive\/\"${logging_dir}\".log <\/pre>\n\n\n\n<p>Runing this script will create a .log file with a simple write to the nvme drive.  Next step wil be to setup a cron task with<\/p>\n\n\n\n<p>sudo crontab -e<\/p>\n\n\n\n<p>add the following lines to enable the script<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># nvme drive keepalive by posting to drive every minute\n *\/1 * * * * sudo sh \/home\/pi\/Scripts\/keepalive\/keepalive.sh<\/pre>\n\n\n\n<p>Now Save and reboot the system.<\/p>\n\n\n\n<p>NOTE<\/p>\n\n\n\n<p>If you are adding this with pihole&#8230;you might want to add the following step which will run when the pi is rebooted.  It tells the pi that when it reboots&#8230;wait 15 seconds and then restart the pihole dns resolution<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># On reboot + 15 seconds restart the pihole dns resolver (loop prevention)\n \n@reboot sleep 15 &amp;&amp; sudo pihole restartdns<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Placed in \/Scripts\/keepalive pi@raspberry01:~\/Scripts\/keepalive$ cat keepalive.sh #bin\/bash ## BAINWERX ## NVME Keepalive Read|Write Script ## version 1.2 ## created Feb 2021 ## Time in 12 hr format logging_time=$(date +&#8217;%r&#8217;) ## backup dir format logging_dir=$(date +&#8217;%m_%d_%Y&#8217;) find \/home\/pi\/Scripts\/keepalive\/*.log -mtime 1 -delete; echo &#8220;NVME Keepalive Read|Write at&#8221; &#8220;${logging_time}&#8221; >> \/home\/pi\/Scripts\/keepalive\/&#8221;${logging_dir}&#8221;.log Runing this script will create a .log &hellip; <a href=\"https:\/\/io.bainwerx.com\/blog\/nvme-drive-keep-alive-script\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">NVME Drive Keep Alive Script<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[75],"tags":[],"class_list":["post-1346","post","type-post","status-publish","format-standard","hentry","category-raspberry-pi","without-featured-image"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8DcKP-lI","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/io.bainwerx.com\/blog\/wp-json\/wp\/v2\/posts\/1346","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/io.bainwerx.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/io.bainwerx.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/io.bainwerx.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/io.bainwerx.com\/blog\/wp-json\/wp\/v2\/comments?post=1346"}],"version-history":[{"count":1,"href":"https:\/\/io.bainwerx.com\/blog\/wp-json\/wp\/v2\/posts\/1346\/revisions"}],"predecessor-version":[{"id":1347,"href":"https:\/\/io.bainwerx.com\/blog\/wp-json\/wp\/v2\/posts\/1346\/revisions\/1347"}],"wp:attachment":[{"href":"https:\/\/io.bainwerx.com\/blog\/wp-json\/wp\/v2\/media?parent=1346"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/io.bainwerx.com\/blog\/wp-json\/wp\/v2\/categories?post=1346"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/io.bainwerx.com\/blog\/wp-json\/wp\/v2\/tags?post=1346"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}