in reply to Net::SSH::Perl with apt-get

Why not write a cron job for the update process and stick it on each machine? I wrote a simple one a while back that has worked pretty good for me.
#!/usr/bin/perl -w ################################################################ # Program: auto-update # Programmer: Elijah # Requires: apt for Red Hat/Fedora # # This app does nightly checks for upgradable system packages. # Simply drop this program in your cron.daily directory # and set to executable (chmod +x). # # Note* # This could cause issues or loss of service, use at your own # risk. If a package is updated and has problems you might not # even be aware of the outage until hours (or days) later. # ############################################################### use strict; my $timestamp = `date`; my @time = split(/ /, $timestamp); my $file = $time[2]."-".$time[1]."-".$time[5]; my $create_log = "/var/log/system-update/$file"; my $grab_list = `apt-get -y update`; my $update_status = `apt-get -y dist-upgrade`; my $clean = `apt-get -y clean`; my $timestamp2 = `date`; open (FILE, ">>$create_log") || die "Cannot open $create_log\n"; print FILE "Log started at: ".$timestamp,"\n\n"; print FILE "###################\n"; print FILE "### List Status ###\n"; print FILE "###################\n"; print FILE $grab_list,"\n\n"; print FILE "##############################\n"; print FILE "### Package Upgrade Status ###\n"; print FILE "##############################\n"; print FILE $update_status,"\n\n"; print FILE "#######################\n"; print FILE "### Clean Up Status ###\n"; print FILE "#######################\n"; if ($clean eq "") { print FILE "Cleanup was successfull!\n\n"; }else{ print FILE $clean,"\n\n"; } print FILE "Log ended at: ".$timestamp2,"\n"; close(FILE);
This would probably be your easiest bet. Just be carefull and read the header about using this to update crucial servers because this will update all new packages and Kernels and that could cause a problem on some systems.

Replies are listed 'Best First'.
Re: Re: Net::SSH::Perl with apt-get
by flyingmoose (Priest) on Feb 14, 2004 at 02:59 UTC

    (off topic)

    I run Fedora myself, but I ran Debian for a good while, and (from experience) with Debian packages, you really want to be there (interactively) to handle the questions Debian will ask you. Things like "keep this version or install the package maintainers version" can be important.

    With Fedora, there is no package configuration on install/upgrade, so it doesn't matter as much. I haven't even seen a testing package ask questions yet.

Re: Re: Net::SSH::Perl with apt-get
by hossman (Prior) on Feb 14, 2004 at 09:15 UTC

    For the record, the point of his script is not to run apt-get update / apt-get dist-upgrade on each of his servers, it's to run "apt-get install $app"

    While you script may be usefull to him, it doesn't address his problem.

      Well it most definately addresses his problem if you would care to even read the source for the script. It really does not matter what he is trying to upgrade (an entire distro list or a single package) the syntax for apt-get is the same.

      What he needed from my script was the "-y" argument telling apt-get to answer yes to all asked questions. You can take my entire script and change a few lines and have it upgrade single packages. So as I am sure you can see now is that yes it does address his problem.

        This is very odd, and not the way I would assume it works. I will have to verify this. For you see, when I run "apt-get install anjuta" on the commandline (without Net::SSH::Perl), it does not require any interaction. We can see the output:
        apt-get install anjuta Reading Package Lists... Done Building Dependency Tree... Done The following NEW packages will be installed: anjuta 0 packages upgraded, 1 newly installed, 0 to remove and 2 not upgrade +d. Need to get 2633kB of archives. After unpacking 6955kB will be used. Get:1 http://ftp.us.debian.org stable/main anjuta 0.1.9-4 [2633kB] Fetched 2633kB in 17s (155kB/s) + Selecting previously deselected package anjuta. (Reading database ... 109891 files and directories currently installed +.) Unpacking anjuta (from .../anjuta_0.1.9-4_i386.deb) ... Setting up anjuta (0.1.9-4) ...
        I will try this again with a -y to see if it works differently.
        Rohit Mehta
        I have just verified that using the "-y" does not produce different results. I think this is more of a Net::SSH::Perl problem than an apt problem :-/
        Rohit Mehta