MeshNook技术与生活的角落

2009.02.04 · 2 分钟阅读

[ubuntu] Automatic apt-get update

  • Install cron-apt

  • # apt-get install cron-apt
  • Edit /etc/cron-apt/config

  • add
    MAILTO="[Your email address]"
    after
    # MAILTO="root"

    add
    MAILON="always"
    after
    # MAILON="error"
  • Configure actions

  • # cd /etc/cron-apt/action.d
    # rm 3-download
    # cat <<EOF>> 1-dist-upgrade
    > autoclean -y
    > dist-upgrade -y -o APT::Get::Show-Upgraded=true
    > EOF

    # cat <<EOF>> 2-upgrade
    > autoclean -y
    > upgrade -t hardy-security -y -o APT::Get::Show-Upgraded=true
    > EOF

    # ls -l
    total 12
    -rw-r--r-- 1 root root 18 2007-10-27 14:52 0-update
    -rw-r--r-- 1 root root 61 2009-02-04 19:29 1-dist-upgrade
    -rw-r--r-- 1 root root 74 2009-02-04 19:30 2-upgrade
  • Test

  • # /usr/sbin/cron-apt
  • Check your email

  • If there is something updated, you will receive an email like
    CRON-APT RUN [/etc/cron-apt/config]: Wed Feb 4 19:34:52 CST 2009
    CRON-APT ACTION: 0-update
    CRON-APT LINE: /usr/bin/apt-get update -o quiet=2
    CRON-APT ACTION: 1-dist-upgrade
    CRON-APT LINE: /usr/bin/apt-get autoclean -y
    Reading package lists...
    Building dependency tree...
    Reading state information...
    Del openoffice.org-help-en-gb 1:3.0.1~rc1-2ubuntu1~hardy1 [6615kB]
    Del openoffice.org-style-human 1:3.0.1~rc1-2ubuntu2~hardy1 [4543kB]
    Del openoffice.org-common 1:3.0.1~rc1-2ubuntu2~hardy1 [17.4MB]
    Del openoffice.org-help-ja 1:3.0.1~rc1-2ubuntu1~hardy1 [10.2MB]
    Del openoffice.org-help-zh-tw 1:3.0.1~rc1-2ubuntu1~hardy1 [7838kB]
    Del python-uno 1:3.0.1~rc1-2ubuntu2~hardy1 [460kB]
    Del openoffice.org-impress 1:3.0.1~rc1-2ubuntu2~hardy1 [472kB]
    Del openoffice.org-gtk 1:3.0.1~rc1-2ubuntu2~hardy1 [154kB]
    Del ttf-opensymbol 1:3.0.1~rc1-2ubuntu2~hardy1 [415kB]
    Del openoffice.org-l10n-en-gb 1:3.0.1~rc1-2ubuntu1~hardy1 [1484kB]
    Del openoffice.org-l10n-zh-tw 1:3.0.1~rc1-2ubuntu1~hardy1 [1379kB]
    Del openoffice.org-core 1:3.0.1~rc1-2ubuntu2~hardy1 [26.6MB]
    Del openoffice.org-help-en-us 1:3.0.1~rc1-2ubuntu1~hardy1 [6683kB]
    Del openoffice.org-l10n-en-za 1:3.0.1~rc1-2ubuntu1~hardy1 [389kB]
    Del openoffice.org-l10n-zh-cn 1:3.0.1~rc1-2ubuntu1~hardy1 [1392kB]
    Del openoffice.org-draw 1:3.0.1~rc1-2ubuntu2~hardy1 [2033kB]
    Del openoffice.org-l10n-common 1:3.0.1~rc1-2ubuntu1~hardy1 [365kB]
    Del openoffice.org-gnome 1:3.0.1~rc1-2ubuntu2~hardy1 [62.9kB]
    Del uno-libs3 1.4+OOo3.0.1~rc1-2ubuntu2~hardy1 [1276kB]
    Del ure 1.4+OOo3.0.1~rc1-2ubuntu2~hardy1 [1580kB]
    Del openoffice.org-calc 1:3.0.1~rc1-2ubuntu2~hardy1 [4325kB]
    Del openoffice.org-base-core 1:3.0.1~rc1-2ubuntu2~hardy1 [548kB]
    Del openoffice.org-writer 1:3.0.1~rc1-2ubuntu2~hardy1 [5638kB]
    Del openoffice.org-help-zh-cn 1:3.0.1~rc1-2ubuntu1~hardy1 [7721kB]
    Del openoffice.org-l10n-ja 1:3.0.1~rc1-2ubuntu1~hardy1 [1412kB]
    CRON-APT LINE: /usr/bin/apt-get dist-upgrade -y -o APT::Get::Show-Upgraded=true
    Reading package lists...
    Building dependency tree...
    Reading state information...
    The following packages will be upgraded:
    ufw xserver-xorg-video-ati xserver-xorg-video-intel
    Preconfiguring packages ...
    3 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
    Need to get 0B/826kB of archives.
    After this operation, 8192B of additional disk space will be used.
    (Reading database ... 150941 files and directories currently installed.)
    Preparing to replace ufw 0.16.2.3 (using .../archives/ufw_0.16.2.4_all.deb) ...
    Unpacking replacement ufw ...
    Preparing to replace xserver-xorg-video-ati 1:6.8.0-1 (using .../xserver-xorg-video-ati_1%3a6.8.0-1ubuntu1_i386.deb) ...
    Unpacking replacement xserver-xorg-video-ati ...
    Preparing to replace xserver-xorg-video-intel 2:2.2.1-1ubuntu13.7 (using .../xserver-xorg-video-intel_2%3a2.2.1-1ubuntu13.8_i386.deb) ...
    Unpacking replacement xserver-xorg-video-intel ...
    Setting up ufw (0.16.2.4) ...
    Installing new version of config file /etc/init.d/ufw ...

    Setting up xserver-xorg-video-ati (1:6.8.0-1ubuntu1) ...
    Setting up xserver-xorg-video-intel (2:2.2.1-1ubuntu13.8) ...

    Processing triggers for libc6 ...
    ldconfig deferred processing now taking place
    CRON-APT ACTION: 2-upgrade
    CRON-APT LINE: /usr/bin/apt-get autoclean -y
    Reading package lists...
    Building dependency tree...
    Reading state information...
    CRON-APT LINE: /usr/bin/apt-get upgrade -t hardy-security -y -o APT::Get::Show-Upgraded=true
    Reading package lists...
    Building dependency tree...
    Reading state information...
    0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.