当我尝试在 Debian 机器上编辑/查看 crontab 时,出现以下错误:
crontabs: No such file or directory
crontabs: mkdir: Operation not permitted
我尝试了所有可用的解决方案,更改 cron 文件的权限,重新安装 cron 等等……但都没有帮助。
问题似乎出在/var/spool/cron/crontabs
。这台机器上没有该目录,我无法创建它。
root@hostname:/etc/cron.monthly# sudo chmod 4774 -R /var/spool/cron
chmod: changing permissions of '/var/spool/cron': Operation not permitted
root@hostname:/var/spool# ls -lha /var/spool/cron/crontabs
ls: cannot access '/var/spool/cron/crontabs': No such file or directory
服务未运行:
root@hostname:~# systemctl status cron
× cron.service - Regular background program processing daemon
Loaded: loaded (/lib/systemd/system/cron.service; enabled; preset: enabled)
Active: failed (Result: exit-code) since Wed 2024-11-06 00:47:13 CET; 1 day 17h ago
Duration: 4ms
Docs: man:cron(8)
Process: 566487 ExecStart=/usr/sbin/cron -f $EXTRA_OPTS (code=exited, status=1/FAILURE)
Main PID: 566487 (code=exited, status=1/FAILURE)
CPU: 3ms
Nov 06 00:47:13 marinero-xs01 systemd[1]: cron.service: Scheduled restart job, restart counter is at 5.
Nov 06 00:47:13 marinero-xs01 systemd[1]: Stopped cron.service - Regular background program processing daemon.
Nov 06 00:47:13 marinero-xs01 systemd[1]: cron.service: Start request repeated too quickly.
Nov 06 00:47:13 marinero-xs01 systemd[1]: cron.service: Failed with result 'exit-code'.
Nov 06 00:47:13 marinero-xs01 systemd[1]: Failed to start cron.service - Regular background program processing daemon.
ls -la
:
root@hostname:~# ls -la /var/spool/cron
total 8
drwxr-xr-x 2 root root 4096 Dec 30 2023 .
drwxr-xr-x 6 root root 4096 Feb 9 2024 ..
版本信息:
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 12 (bookworm)
Release: 12
Codename: bookworm
6
–
sudo apt install cron
?–
apt install --reinstall cron
,结果一样。–
–
ls -la /var/spool/cron
至少向我们展示一下。而且,我问你关于容器的原因是,root 无法更改所有者或权限的情况对于设置不当的非特权容器来说是典型的。如果文件由未映射到容器 ID 范围的某个 ID 拥有,则“内部”root 对它们无权。所以我正要要求从主机角度提供该文件的模式。可以通过在容器外小心地做事或正确地重新创建它来修复它,但由于你不是维护者,你可能无法做到这一点……–
|