升级后不允许 Crontab 权限

升级后不允许 Crontab 权限

我已经将 Ubuntu 从 20.04 升级到 22.04,但升级似乎未成功完成。当我尝试安装新软件包时,例如:sudo apt install virtualenv我收到以下错误:

Do you want to continue? [Y/n] y
Setting up cron (3.0pl1-137ubuntu3) ...
Installing new version of config file /etc/crontab ...
dpkg: error processing package cron (--configure):
 unable to install '/etc/crontab.dpkg-new' as '/etc/crontab': Operation not permitted
Errors were encountered while processing:
 cron
needrestart is being skipped since dpkg has failed
E: Sub-process /usr/bin/dpkg returned an error code (1)

无论哪个包都会出现此错误。我已关注其他问题并检查了权限/etc/cron.droot可以访问所有权限,我甚至可以创建一个新的cron job并触发它,但是当安装新包时,错误仍然存​​在。我已经检查过systemctlcron服务处于活动状态并运行良好。

● cron.service - Regular background program processing daemon
     Loaded: loaded (/lib/systemd/system/cron.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2023-02-15 14:56:10 UTC; 17min ago
       Docs: man:cron(8)
   Main PID: 59355 (cron)
      Tasks: 185 (limit: 18962)
     Memory: 114.7M
        CPU: 317ms
     CGroup: /system.slice/cron.service

安装过程中可能出现什么问题导致出现此问题?


更新:

问题仍然存在,但是我注意到 @steelworker 和 @jos 建议后发生了变化。现在,当我尝试安装时,错误是另一个错误:

Do you want to continue? [Y/n] y
Setting up cron (3.0pl1-137ubuntu3) ...
chown: changing ownership of '/var/spool/cron/crontabs': 
Operation not permitted
dpkg: error processing package cron (--configure):
installed cron package post-installation script subprocess 
returned error exit status 1
Errors were encountered while processing:

执行sudo ls -la /var/spool/cron/crontabs结果是:

total 12
drwx-wx--T 2 root crontab 4096 Nov 14  2021 .
drwxr-xr-x 5 root root    4096 Oct 26  2020 ..
-rw------- 1 git  crontab  250 Nov 14  2021 git

并返回上一级的内容:

drwxr-xr-x 5 root   root    4096 Oct 26  2020 .
drwxr-xr-x 4 root   root    4096 Oct 26  2020 ..
drwxrwx--T 2 daemon daemon  4096 Oct 26  2020 atjobs
drwxrwx--T 2 daemon daemon  4096 Nov 12  2018 atspool
drwx-wx--T 2 root   crontab 4096 Nov 14  2021 crontabs

相关内容