因為資安的問題,所以作業系統或是程式都要常做更新,才能確保系統的安全。在作業系統或程式更新的時候,我通常喜歡自己決定更新的時候或是更新的套件,因為有時候,太快更新或是自動更新,可能會造成災難,所以能自行掌握更新時間點,會是比較好的事,但這會造成使用者的一些負擔,必須要常常去注意相關的訊息。
參考網頁:力力皆辛苦: [Ubuntu]啟用Ubuntu 自動安全更新與設定E-mail通知
Ubuntu Linux 在登入時,系統會有提示可以更新的套件
Welcome to Ubuntu 12.04.5 LTS (GNU/Linux 3.2.0-74-generic-pae i686)
* Documentation: https://help.ubuntu.com/
System information as of Tue Jan 20 08:28:27 CST 2015
System load: 0.0 Processes: 80
Usage of /: 7.8% of 72.05GB Users logged in: 1
Memory usage: 24% IP address for eth0: 140.111.xx.xx
Swap usage: 0%
Graph this data and manage this system at:
https://landscape.canonical.com/
25 packages can be updated.
24 updates are security updates.
New release ‘trusty’ available.
Run ‘do-release-upgrade’ to upgrade to it.[@more@]但管理者並不一定會常常登入系統,所以改用 apt-get -s upgrade 的指令來查詢出可以更新的套件,再配合 crontab 和 mail,當系統有套件可以更新時,寄信通知管理者。
# vim /usr/local/bin/check-update
#!/bin/bash
apt-get update > /dev/null 2>&1
apt-get -s upgrade | grep Inst | awk ‘{print $2,$3}’ > /tmp/$(date +%F)
if [ -s /tmp/$(date +%F) ] ;then
mail -s “Ubuntu Linux Updates Available” xxx@gmail.com < /tmp/$(date +%F)
rm -rf /tmp/$(date +%F)
else
rm -rf /tmp/$(date +%F)
fi
更改權限
# chmod 700 /usr/local/bin/check-update
加入工作排程
# crontab -e
0 3 * * * /usr/lcoal/bin/check-update