我正在尝试使用cron自动执行系统更新。您可以在下面查看我的crontab,命令和产生的错误。
当我以root用户身份运行upgrades.sh时,脚本运行良好。当cron运行它时,apt-get -y update
没有问题,但是aptitude -y safe-upgrade
失败了。我猜是这个错误:debconf: (This frontend requires a controlling tty.)
是因为有一个内核更新,而内核更新又更新了grub,这需要我明确地说可以覆盖/boot/grub/menu.lst
。但是我不明白路径错误。我想要不需要我监督的更新。
我已经阅读了这个问题,它是尚不可接受的解决方案unattended-upgrades
,我可能最终会使用它,但是为什么不能使用cron?似乎它应该非常简单,并且更加Linuxy。
Crontab
root@daedalus:~/bin# crontab -l
# m h dom mon dow command
45 06 * * * ~/bin/upgrades.sh
upgrades.sh
root@daedalus:~/bin# cat upgrades.sh
#!/bin/bash
/usr/bin/apt-get -y update
/usr/bin/aptitude -y safe-upgrade
失误
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:
Fetched 37.6MB in 4min 23s (143kB/s)
dpkg: warning: 'ldconfig' not found on PATH.
dpkg: warning: 'start-stop-daemon' not found on PATH.
dpkg: warning: 'update-rc.d' not found on PATH.
dpkg: 3 expected program(s) not found on PATH.
NB: root's PATH should usually contain /usr/local/sbin, /usr/sbin and /sbin.
E: Sub-process /usr/bin/dpkg returned an error code (2)
A package failed to install. Trying to recover:
dpkg: warning: 'ldconfig' not found on PATH.
dpkg: warning: 'start-stop-daemon' not found on PATH.
dpkg: warning: 'update-rc.d' not found on PATH.
dpkg: 3 expected program(s) not found on PATH.
NB: root's PATH should usually contain /usr/local/sbin, /usr/sbin and /sbin.
Reading package lists...
Building dependency tree...
Reading state information...
Reading extended state information...
Initializing package states...
Writing extended state information...