#!/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);