列出系統可以升級的套件
# emerge -pv world | grep “[ebuild U ]” | awk ‘{print $4}’ | awk -F ‘/’ ‘{print $2}’
procps-3.3.9-r2
列出系統已安裝套件
# emerge -pv world | grep “[ebuild R ]” | awk ‘{print $4}’ | awk -F ‘/’ ‘{print $2}’ | head
xz-utils-5.0.8
bzip2-1.0.6-r6
gnuconfig-20140212
which-2.20-r1
baselayout-2.2
patch-2.6.1
os-headers-0
file-5.21
net-tools-1.60_p20130513023548
coreutils-8.21[@more@]利用 gmail 來寄信
1. 安裝 ssmtp 及 mailx
# emerge ssmtp mailx
2. 備份原設定檔 /etc/ssmtp/ssmtp.conf
# cp /etc/ssmtp/ssmtp.conf /etc/ssmtp/ssmtp.conf.$(date +%F)
3. 修改設定檔 /etc/ssmtp/ssmtp.conf
# vim /etc/ssmtp/ssmtp.conf
#root=postmaster
# The place where the mail goes. The actual machine name is required
# no MX records are consulted. Commonly mailhosts are named mail.domain.com
# The example will fit if you are in domain.com and you mailhub is so named.
mailhub=smtp.gmail.com:587
# Where will the mail seem to come from?
#rewriteDomain=y
# The full hostname
#hostname=root-chroot-copy
# 寄件者帳號
AuthUser=xxxx@gmail.com
# 寄件者密碼
AuthPass=xxxx
UseSTARTTLS=YES
FromLineOverride=yes #enables to use mail -r option
4. 更改檔案權限
# chmod 0600 /etc/ssmtp/ssmtp.conf
5. 建立 Script
# cat /usr/lcoal/bin/check-update
#!/bin/bash
emerge -pv world | grep “[ebuild U ]” | awk ‘{print $4}’ | awk -F ‘/’ ‘{print $2}’ > /tmp/$(date +%F)
if [ -s /tmp/$(date +%F) ] ;then
mail -s “Gentoo Linux Updates Available” xxxx@gmail.com < /tmp/$(date +%F)
rm -rf /tmp/$(date +%F)
else
rm -rf /tmp/$(date +%F)
fi
6. 更改檔案執行權限
# chmod 700 /usr/lcoal/bin/check-update
7. 排程(每 3 小時執行一次)
# crontab -l
0 3 * * * /usr/lcoal/bin/check-update



















