使用crontab執行apt-get出現錯誤 - Linux

Table of Contents

[問題描述]無法使用crontab自動執行apt-get更新

sudo crontab -l
# m h dom mon dow command
0 3 * * * sh /home/username/crontab.sh

vim /home/username/crontab.sh
#!/bin/bash
PATH=/usr/bin:/bin:/usr/sbin:/sbin
apt-get -qq update 2>> /home/username/crontab_$(date '+%Y_%m_%d').log
apt-get -qq dist-upgrade 2>> /home/username/crontab_$(date '+%Y_%m_%d').log

Error Log
debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (This frontend requires a controlling tty.)
debconf: falling back to frontend: Teletype
dpkg-preconfigure: unable to re-open stdin:
......

請問應如何修正??
謝謝

--

All Comments

Jacob avatarJacob2013-03-19
這ip是建中?為啥要打一長串 apt-get update && apt-ge
t dist-upgrade -y --force-yes 直接寫在crontab 後面
不就好?