{"id":919,"date":"2017-10-19T15:26:19","date_gmt":"2017-10-19T20:26:19","guid":{"rendered":"http:\/\/sites.williams.edu\/lj1\/?p=919"},"modified":"2017-10-19T15:41:54","modified_gmt":"2017-10-19T20:41:54","slug":"mac-os-remove-inactive-users","status":"publish","type":"post","link":"https:\/\/sites.williams.edu\/lj1\/labs\/mac-os-remove-inactive-users\/","title":{"rendered":"Mac OS &#8211; Remove Inactive Users"},"content":{"rendered":"<p>Each user that logs into one of the macs I support takes up almost 500 MB of space for their &#8220;home&#8221; directory. With some of my macs having hundreds of users these home directories can fill up the disk. Also, on my macs, AD users don&#8217;t create an account on the machine but they do create a home directory.\u00a0 Therefore, I don&#8217;t have an account to remove, just the home directory.<\/p>\n<p>I created this script to search for and remove the user&#8217;s home directory for users that have not logged in in over 14 days.\u00a0 Using our JAMF server I can target macs with a disk that is 80% or more full to run this script.<\/p>\n<pre>#!\/bin\/sh\r\n# Lynna Jackson, Williams College, Oct 19 2017\r\n\r\n#finds users who haven't logged in in over 21 days and if they \r\n#aren't a \"protected\" account, deletes the user's directory\r\nusersToDelete=`find \/Users -type d -maxdepth 1 -mindepth 1 -mtime +14`   \r\n\r\nfor a in $usersToDelete ; do\r\ncase \"$a\" in \"\/Users\/labadmin\"|\"\/Users\/Shared\"|\"\/Users\/root\") \r\n  # Don't delete these accounts \r\n  echo \"\"$a\" Protected User Not being deleted\"\r\n  ;;\r\n  *)\r\n    echo \"Deleting: \"$a\"\"\r\n    rm -R \"$a\"  \r\n  ;;\r\nesac\r\ndone\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Each user that logs into one of the macs I support takes up almost 500 MB of space for their &#8220;home&#8221; directory. With some of my macs having hundreds of users these home directories can fill up the disk. Also, &hellip; <a class=\"more-link\" href=\"https:\/\/sites.williams.edu\/lj1\/labs\/mac-os-remove-inactive-users\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":55,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[10086],"tags":[10090,10092],"class_list":["post-919","post","type-post","status-publish","format-standard","hentry","category-labs","tag-mac","tag-user-profile"],"acf":[],"_links":{"self":[{"href":"https:\/\/sites.williams.edu\/lj1\/wp-json\/wp\/v2\/posts\/919","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sites.williams.edu\/lj1\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sites.williams.edu\/lj1\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sites.williams.edu\/lj1\/wp-json\/wp\/v2\/users\/55"}],"replies":[{"embeddable":true,"href":"https:\/\/sites.williams.edu\/lj1\/wp-json\/wp\/v2\/comments?post=919"}],"version-history":[{"count":5,"href":"https:\/\/sites.williams.edu\/lj1\/wp-json\/wp\/v2\/posts\/919\/revisions"}],"predecessor-version":[{"id":924,"href":"https:\/\/sites.williams.edu\/lj1\/wp-json\/wp\/v2\/posts\/919\/revisions\/924"}],"wp:attachment":[{"href":"https:\/\/sites.williams.edu\/lj1\/wp-json\/wp\/v2\/media?parent=919"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sites.williams.edu\/lj1\/wp-json\/wp\/v2\/categories?post=919"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sites.williams.edu\/lj1\/wp-json\/wp\/v2\/tags?post=919"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}