I have upgraded Ubuntu from 20.04 to 22.04 but the upgrade doesn't seem to have completed successfully. When I try to install a new package, as an example: sudo apt install virtualenv
I get the following error:
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)
Regardless of package this error appears. I have followed other questions and checked permissions in /etc/cron.d
, root
has access to all, I can even create a new cron job
and trigger it however when it comes to installing new packages the error still persists. I have checked systemctl
and cron
service is active and running just fine.
● 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
What could have gone wrong during the installation for this issue to occur?
Update:
The issue still remains however I've noticed a change after @steelworker and @jos recommendations. Now when I try to install there error is a different error:
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:
When executing sudo ls -la /var/spool/cron/crontabs
this is the result:
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
and one level up this is returned:
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