今天為了找一個 dpkg 被 lock 的問題,意外發現系統有裝 cron-apt
平時如果想要自動做 update/upgrade package, 就可以使用這個,
apt-get install cron-tab
安裝好之後,會發現在 /etc/cron.d 下多了一個 cron-apt 檔案, 內容就是每天 4 點鐘自動執行 cron-apt
#
# Regular cron jobs for the cron-apt package
#
# Every night at 4 o'clock.
0 4 * * * root test -x /usr/sbin/cron-apt && /usr/sbin/cron-apt
# Every hour.
# 0 * * * * root test -x /usr/sbin/cron-apt && /usr/sbin/cron-apt /etc/cron-apt/config2
# Every five minutes.
# */5 * * * * root test -x /usr/sbin/cron-apt && /usr/sbin/cron-apt /etc/cron-apt/config2
另外可以看一下 /etc/cron-apt/action.d, 就知道 cron-apt 做了那些事
預設是只做 update repository list 以及 download new packages
/etc/cron-apt/action.d$ ls
0-update 3-download
/etc/cron-apt/action.d$ cat 0-update
update -o quiet=2
/etc/cron-apt/action.d$ cat 3-download
autoclean -y
dist-upgrade -d -y -o APT::Get::Show-Upgraded=true
相關的 log 可以看 /var/log/cron-apt/log
CRON-APT RUN [/etc/cron-apt/config]: Tue Jun 25 04:00:01 BST 2013
CRON-APT SLEEP: 2274, Tue Jun 25 04:37:55 BST 2013
CRON-APT ACTION: 0-update
CRON-APT LINE: /usr/bin/apt-get -o quiet=1 update -o quiet=2
CRON-APT ACTION: 3-download
CRON-APT LINE: /usr/bin/apt-get -o quiet=1 autoclean -y
Reading package lists...
Building dependency tree...
Reading state information...
CRON-APT LINE: /usr/bin/apt-get -o quiet=1 dist-upgrade -d -y -o APT::Get::Show-Upgraded=true
Reading package lists...
Building dependency tree...
Reading state information...
The following NEW packages will be installed:
ruby-rgen
The following packages will be upgraded:
cpan-libnet-http-perl facter libpython2.7 libvirt0 nodejs puppet
puppet-common puppetmaster puppetmaster-common python python-dev
python-django python-minimal python2.7 python2.7-dev python2.7-minimal
uwsgi-core uwsgi-plugin-carbon uwsgi-plugin-cgi uwsgi-plugin-corerouter
uwsgi-plugin-http uwsgi-plugin-psgi uwsgi-plugin-python
uwsgi-plugin-rack-ruby1.8 uwsgi-plugin-rack-ruby1.9.1
25 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/49.3 MB of archives.
After this operation, 5977 kB of additional disk space will be used.
Download complete and in download only mode
Reference:
http://www.the-art-of-web.com/system/cron-apt-wheezy/#.UckR2hoW1Xo
http://www.debianadmin.com/automatic-update-of-packages-using-cron-apt.html
http://www.techrepublic.com/article/automatically-update-your-ubuntu-system-with-cron-apt/6310660