#!/opt/perluseEmail::Sender::Simpleqw(sendmail);useEmail::Simple;useSys::Syslog;useSys::Hostname;useIPC::System::Simpleqw(run);useFcntlqw(LOCK_EX LOCK_NB);open(my$fh,'<',$0)ordie("Unable to open $0");if(!flock($fh,LOCK_EX|LOCK_NB)){die("another instance is running");}eval{my$cmd="/usr/bin/yum --quiet check-update 1>/dev/null";if(run([0,100],$cmd)==100){mail_me();}else{info("no updates");}};if($@){info("issue: $@");}submail_me{my$mail=Email::Simple->create(header=>[To=>readlink("$ENV{HOME}/email"),From=>sprintf('yum_updates@%s',hostname),],body=>"There are yum updates available",);sendmail($mail);}subinfo{openlog("yum_chk",'cons,pid','user');syslog('info',@_);closelog();}
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.