注意到我的 cron 作业没有运行(不确定持续了多久,可能是因为我两周前升级到 16.04),而且我无法启动服务。
root@wormhole:~# systemctl start cron.service
Job for cron.service failed because the control process exited with error code. See "systemctl status cron.service" and "journalctl -xe" for details.
root@wormhole:~# systemctl status cron.service
● cron.service
Loaded: loaded (/etc/init.d/cron; bad; vendor preset: enabled)
Active: failed (Result: exit-code) since Wed 2019-02-20 23:02:57 EST; 6s ago
Docs: man:systemd-sysv-generator(8)
Process: 8340 ExecStart=/etc/init.d/cron start (code=exited, status=1/FAILURE)
Feb 20 23:02:57 wormhole cron[8340]: Rather than invoking init scripts through /etc/init.d, use the service(8)
Feb 20 23:02:57 wormhole cron[8340]: utility, e.g. service cron start
Feb 20 23:02:57 wormhole cron[8340]: initctl: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused
Feb 20 23:02:57 wormhole cron[8340]: Since the script you are attempting to invoke has been converted to an
Feb 20 23:02:57 wormhole cron[8340]: Upstart job, you may also use the start(8) utility, e.g. start cron
Feb 20 23:02:57 wormhole cron[8340]: start: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused
Feb 20 23:02:57 wormhole systemd[1]: cron.service: Control process exited, code=exited status=1
Feb 20 23:02:57 wormhole systemd[1]: Failed to start cron.service.
Feb 20 23:02:57 wormhole systemd[1]: cron.service: Unit entered failed state.
Feb 20 23:02:57 wormhole systemd[1]: cron.service: Failed with result 'exit-code'.
答案1
从 14.04 升级到 16.04 并不完全成功,我使用的是旧版本的 cron。解决方法是:
sudo apt-get install --fix-missing
sudo dpkg --configure -a
sudo apt-get install cron