{"id":358,"date":"2013-05-13T06:42:20","date_gmt":"2013-05-13T06:42:20","guid":{"rendered":"https:\/\/shan.info\/new\/auto-update-an-debian-server-with-aptitude\/"},"modified":"2013-05-13T06:42:20","modified_gmt":"2013-05-13T06:42:20","slug":"auto-update-an-debian-server-with-aptitude","status":"publish","type":"post","link":"https:\/\/shan.info\/new\/auto-update-an-debian-server-with-aptitude\/","title":{"rendered":"Auto update an debian Server with Aptitude"},"content":{"rendered":"<h2 class=\"dropcap\" style=\"margin: 0px 0px 1em; padding: 0px; border: 0px; font-family: Georgia, serif; font-size: 1.26562em; line-height: 1.77777em; vertical-align: baseline; text-rendering: optimizelegibility; color: #000000;\">How to keep software up-to-date automatically on Ubuntu Server using Aptitude<\/h2>\n<h2 style=\"margin: 0px 0px 1em; padding: 0px; border: 0px; font-family: Georgia, serif; font-size: 1.26562em; line-height: 1.77777em; vertical-align: baseline; text-rendering: optimizelegibility; color: #000000;\">Usual disclaimer<\/h2>\n<p style=\"margin: 0px 0px 1.5em; padding: 0px; border: 0px; font-family: Georgia, serif; font-size: 18px; line-height: 31.5px; vertical-align: baseline; -webkit-hyphens: auto; color: #000000;\">This article is provided as it and no responsibility will be taken for things going wrong. Tested on Ubuntu 8.10 server.<\/p>\n<h2 style=\"margin: 0px 0px 1em; padding: 0px; border: 0px; font-family: Georgia, serif; font-size: 1.26562em; line-height: 1.77777em; vertical-align: baseline; text-rendering: optimizelegibility; color: #000000;\">Using Aptitude<\/h2>\n<p style=\"margin: 0px 0px 1.5em; padding: 0px; border: 0px; font-family: Georgia, serif; font-size: 18px; line-height: 31.5px; vertical-align: baseline; -webkit-hyphens: auto; color: #000000;\">If you&#8217;ve ever tried out Ubuntu you&#8217;ll probably know what aptitude is and how to manage packages. Updating your system is as simple as sudo aptitude udpate &amp;&amp; sudo aptitude upgrade<\/p>\n<p style=\"margin: 0px 0px 1.5em; padding: 0px; border: 0px; font-family: Georgia, serif; font-size: 18px; line-height: 31.5px; vertical-align: baseline; -webkit-hyphens: auto; color: #000000;\">This updates the package lists and presents any upgrades.<\/p>\n<h2 style=\"margin: 0px 0px 1em; padding: 0px; border: 0px; font-family: Georgia, serif; font-size: 1.26562em; line-height: 1.77777em; vertical-align: baseline; text-rendering: optimizelegibility; color: #000000;\">Automating the process<\/h2>\n<p style=\"margin: 0px 0px 1.5em; padding: 0px; border: 0px; font-family: Georgia, serif; font-size: 18px; line-height: 31.5px; vertical-align: baseline; -webkit-hyphens: auto; color: #000000;\">Wouldn&#8217;t it be easier if you could automate this and forget about it? That way your server can stay up to date without you ever having to worry about it. Create a file called autoupdate.sh and put the following into it:<\/p>\n<pre style=\"margin: 0px 0px 3em; padding: 1.5em 1em; border: 0px; font-family: monospace, monospace; font-size: 0.9375em; line-height: 1em; vertical-align: baseline; -webkit-font-smoothing: subpixel-antialiased; color: #5a5a5a; white-space: pre-wrap; word-wrap: break-word;\"><code class=\"bash\" style=\"margin: 0px; padding: 0.5em; border: 0px; font-family: monospace, monospace; font-size: 0.9375em; line-height: 1.26562em; vertical-align: baseline; -webkit-font-smoothing: subpixel-antialiased; display: block; background-color: #002b36; color: #839496;\"><span class=\"shebang\" style=\"margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; color: #cb4b16;\">#!\/bin\/bash<\/span>\r\n\r\n<span class=\"comment\" style=\"margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: italic; font-variant: inherit; line-height: inherit; vertical-align: baseline; color: #586e75;\"># A script to run Aptitude and install any upgrades automatically. <\/span>\r\n<span class=\"comment\" style=\"margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: italic; font-variant: inherit; line-height: inherit; vertical-align: baseline; color: #586e75;\"># Add this to \/etc\/cron.daily to run the script every 24 hours. <\/span>\r\n\r\n<span class=\"comment\" style=\"margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: italic; font-variant: inherit; line-height: inherit; vertical-align: baseline; color: #586e75;\"># This prevents \"TERM is not set, so the dialog frontend is not usable.\" error<\/span>\r\nPATH=<span class=\"string\" style=\"margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; color: #2aa198;\">\"<span class=\"variable\" style=\"margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; color: #b58900;\">$PATH<\/span>:\/usr\/local\/bin:\/usr\/local\/sbin:\/usr\/bin:\/usr\/sbin:\/bin:\/sbin\"<\/span>\r\n\r\naptitude update\r\naptitude safe-upgrade -y\r\naptitude autoclean<\/code><\/pre>\n<p style=\"margin: 0px 0px 1.5em; padding: 0px; border: 0px; font-family: Georgia, serif; font-size: 18px; line-height: 31.5px; vertical-align: baseline; -webkit-hyphens: auto; color: #000000;\">To run this script daily move it to \/etc\/cron.daily (making sure it is executable).<\/p>\n<pre style=\"margin: 0px 0px 3em; padding: 1.5em 1em; border: 0px; font-family: monospace, monospace; font-size: 0.9375em; line-height: 1em; vertical-align: baseline; -webkit-font-smoothing: subpixel-antialiased; color: #5a5a5a; white-space: pre-wrap; word-wrap: break-word;\"><code class=\"sql\" style=\"margin: 0px; padding: 0.5em; border: 0px; font-family: monospace, monospace; font-size: 0.9375em; line-height: 1.26562em; vertical-align: baseline; -webkit-font-smoothing: subpixel-antialiased; display: block; background-color: #002b36; color: #839496;\"><span style=\"color: #839496; font-family: monospace, monospace;\"><span style=\"font-size: 0.9375em; line-height: 1.26562em; white-space: pre-wrap;\">chmod +x auto<\/span><\/span><span class=\"operator\" style=\"margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline;\"><span class=\"keyword\" style=\"margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; color: #859900;\">update<\/span><span style=\"color: #839496; font-family: inherit;\"><span style=\"font-style: inherit; font-variant: inherit; line-height: inherit; white-space: pre-wrap;\">.sh\r\nsudo chown root:root autoupdate.sh\r\nsudo mv autoupdate.sh \/etc\/cron.daily <br \/><br \/><br \/><br \/>test<br \/><\/span><\/span><span style=\"color: #839496; font-family: monospace, monospace;\"><span style=\"line-height: 15.171875px; white-space: pre-wrap;\">\r\ncd \/etc\/cron.daily \r\n\r\n.\/autoupdate.sh<\/span><\/span><span style=\"color: #839496; font-family: inherit;\"><span style=\"font-style: inherit; font-variant: inherit; line-height: inherit; white-space: pre-wrap;\"><br \/><\/span><\/span><span style=\"color: #839496; font-family: inherit;\"><span style=\"font-style: inherit; font-variant: inherit; line-height: inherit; white-space: pre-wrap;\"><br \/><\/span><\/span><\/span><\/code><\/pre>\n<p style=\"margin: 0px 0px 1.5em; padding: 0px; border: 0px; font-family: Georgia, serif; font-size: 18px; line-height: 31.5px; vertical-align: baseline; -webkit-hyphens: auto; color: #000000;\">The update will run automatically once a day ensuring you stay up-to-date.<\/p>\n<h2 style=\"margin: 0px 0px 1em; padding: 0px; border: 0px; font-family: Georgia, serif; font-size: 1.26562em; line-height: 1.77777em; vertical-align: baseline; text-rendering: optimizelegibility; color: #000000;\">Checking logs<\/h2>\n<p style=\"margin: 0px 0px 1.5em; padding: 0px; border: 0px; font-family: Georgia, serif; font-size: 18px; line-height: 31.5px; vertical-align: baseline; -webkit-hyphens: auto; color: #000000;\">You can keep a check on packages that have been installed and removed via the log file that Aptitude generates.<\/p>\n<pre style=\"margin: 0px 0px 3em; padding: 1.5em 1em; border: 0px; font-family: monospace, monospace; font-size: 0.9375em; line-height: 1em; vertical-align: baseline; -webkit-font-smoothing: subpixel-antialiased; color: #5a5a5a; white-space: pre-wrap; word-wrap: break-word;\"><code class=\"sql\" style=\"margin: 0px; padding: 0.5em; border: 0px; font-family: monospace, monospace; font-size: 0.9375em; line-height: 1.26562em; vertical-align: baseline; -webkit-font-smoothing: subpixel-antialiased; display: block; background-color: #002b36; color: #839496;\">su<span class=\"operator\" style=\"margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline;\"><span class=\"keyword\" style=\"margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; color: #859900;\">do<\/span> tail -n <span class=\"number\" style=\"margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; color: #2aa198;\">30<\/span> \/var\/log\/aptitude<\/span><\/code><\/pre>\n<p style=\"margin: 0px 0px 1.5em; padding: 0px; border: 0px; font-family: Georgia, serif; font-size: 18px; line-height: 31.5px; vertical-align: baseline; -webkit-hyphens: auto; color: #000000;\">If you want to check that an upgrade has been applied you can search for it like this<\/p>\n<pre style=\"margin: 0px 0px 3em; padding: 1.5em 1em; border: 0px; font-family: monospace, monospace; font-size: 0.9375em; line-height: 1em; vertical-align: baseline; -webkit-font-smoothing: subpixel-antialiased; color: #5a5a5a; white-space: pre-wrap; word-wrap: break-word;\"><code class=\"sql\" style=\"margin: 0px; padding: 0.5em; border: 0px; font-family: monospace, monospace; font-size: 0.9375em; line-height: 1.26562em; vertical-align: baseline; -webkit-font-smoothing: subpixel-antialiased; display: block; background-color: #002b36; color: #839496;\">su<span class=\"operator\" style=\"margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline;\"><span class=\"keyword\" style=\"margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; color: #859900;\">do<\/span> cat \/var\/log\/aptitude | grep -A <span class=\"number\" style=\"margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; color: #2aa198;\">20<\/span> -B <span class=\"number\" style=\"margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; color: #2aa198;\">20<\/span> php5<\/span><\/code><\/pre>\n<p style=\"margin: 0px 0px 1.5em; padding: 0px; border: 0px; font-family: Georgia, serif; font-size: 18px; line-height: 31.5px; vertical-align: baseline; -webkit-hyphens: auto; color: #000000;\">Or you can check the currently installed version using (this example is php5)<\/p>\n<pre style=\"margin: 0px 0px 3em; padding: 1.5em 1em; border: 0px; font-family: monospace, monospace; font-size: 0.9375em; line-height: 1em; vertical-align: baseline; -webkit-font-smoothing: subpixel-antialiased; color: #5a5a5a; white-space: pre-wrap; word-wrap: break-word;\"><code class=\"sql\" style=\"margin: 0px; padding: 0.5em; border: 0px; font-family: monospace, monospace; font-size: 0.9375em; line-height: 1.26562em; vertical-align: baseline; -webkit-font-smoothing: subpixel-antialiased; display: block; background-color: #002b36; color: #839496;\">aptitude <span class=\"operator\" style=\"margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline;\"><span class=\"keyword\" style=\"margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; color: #859900;\">show<\/span> php5<\/span><\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>How to keep software up-to-date automatically on Ubuntu Server using Aptitude Usual disclaimer This article is provided as it and no responsibility will be taken for things going wrong. Tested on Ubuntu 8.10 server. Using Aptitude If you&#8217;ve ever tried out Ubuntu you&#8217;ll probably know what aptitude is and how to manage packages. Updating your [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[31],"tags":[],"class_list":["post-358","post","type-post","status-publish","format-standard","hentry","category-debian"],"_links":{"self":[{"href":"https:\/\/shan.info\/new\/wp-json\/wp\/v2\/posts\/358","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/shan.info\/new\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/shan.info\/new\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/shan.info\/new\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/shan.info\/new\/wp-json\/wp\/v2\/comments?post=358"}],"version-history":[{"count":0,"href":"https:\/\/shan.info\/new\/wp-json\/wp\/v2\/posts\/358\/revisions"}],"wp:attachment":[{"href":"https:\/\/shan.info\/new\/wp-json\/wp\/v2\/media?parent=358"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/shan.info\/new\/wp-json\/wp\/v2\/categories?post=358"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/shan.info\/new\/wp-json\/wp\/v2\/tags?post=358"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}