Skip to content

Instantly share code, notes, and snippets.

@worldwise001 worldwise001/autoupdate.sh
Last active Jun 13, 2019

Embed
What would you like to do?
autoupdate.sh (ArchLinux)
#!/bin/bash
timestamp=`date +%s`
logfile=/var/log/autoupdate/${timestamp}.log
hostname=`hostname`
pacupdate() {
yes | pacman -Scc
yes | pacman -Syu --ignore pacman,glibc,linux-lts,linux-lts-headers,linux,linux-headers,systemd,systemd-sysvcompat,libsystemd --noprogressbar &>> $logfile
yes | pacman -Scc
}
mkdir /var/log/autoupdate > /dev/null 2>&1
echo "=== START UPDATE AT $timestamp ===" > $logfile
echo >> $logfile
timed=$((time pacupdate) 2>&1)
result=$?
echo >> $logfile
echo "Result: $result" >> $logfile
echo "$timed" >> $logfile
echo >> $logfile
echo "=== END UPDATE AT $timestamp ===" >> $logfile
cat $logfile | mail -s "pacman on $hostname" root
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.