错误。我尝试了所有可能的 crontab 条目,但没有任何内容被接受。总是path too long
# crontab -e
no crontab for root - using an empty one
crontab: installing new crontab
path too long
crontab: edits left in /tmp/crontab.mqtSoV
[root@myhostname5 tmp]# cat /tmp/crontab.mqtSoV
0 * * * * /tmp/test.sh
红帽发布
# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.1 (Maipo)
日志。在其他日志和journalctl中没有与cron相关的错误。
Sep 5 10:01:01 myhostname5 run-parts(/etc/cron.hourly)[831]: starting 0anacron
Sep 5 10:01:01 myhostname5 run-parts(/etc/cron.hourly)[877]: finished 0anacron
Sep 5 10:01:01 myhostname5 run-parts(/etc/cron.hourly)[831]: starting 0yum-hourly.cron
Sep 5 10:01:02 myhostname5 run-parts(/etc/cron.hourly)[886]: finished 0yum-hourly.cron
Sep 5 10:10:01 myhostname5 CROND[1808]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Sep 5 10:20:02 myhostname5 CROND[4266]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Sep 5 10:30:01 myhostname5 CROND[6182]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Sep 5 10:40:01 myhostname5 CROND[6825]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Sep 5 10:50:01 myhostname5 CROND[8084]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Sep 5 11:00:01 myhostname5 CROND[9467]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Sep 5 11:01:01 myhostname5 CROND[9737]: (root) CMD (run-parts /etc/cron.hourly)
Sep 5 11:01:01 myhostname5 run-parts(/etc/cron.hourly)[9737]: starting 0anacron
Sep 5 11:01:01 myhostname5 run-parts(/etc/cron.hourly)[9746]: finished 0anacron
Sep 5 11:01:01 myhostname5 run-parts(/etc/cron.hourly)[9737]: starting 0yum-hourly.cron
Sep 5 11:01:01 myhostname5 run-parts(/etc/cron.hourly)[9752]: finished 0yum-hourly.cron
Sep 5 11:02:16 myhostname5 crontab[9923]: (root) BEGIN EDIT (root)
Sep 5 11:03:36 myhostname5 crontab[9923]: (root) END EDIT (root)
Sep 5 11:03:50 myhostname5 crontab[10043]: (root) LIST (root)
Sep 5 11:04:02 myhostname5 crontab[10057]: (root) BEGIN EDIT (root)
Sep 5 11:04:10 myhostname5 crontab[10057]: (root) END EDIT (root)
Sep 5 11:04:13 myhostname5 crontab[10082]: (root) LIST (root)
Sep 5 11:04:29 myhostname5 crontab[10106]: (root) BEGIN EDIT (root)
Sep 5 11:04:47 myhostname5 crontab[10106]: (root) END EDIT (root)
Sep 5 11:05:13 myhostname5 crontab[10150]: (root) BEGIN EDIT (root)
Sep 5 11:05:20 myhostname5 crontab[10150]: (root) END EDIT (root)
Sep 5 11:05:45 myhostname5 crontab[10202]: (root) BEGIN EDIT (root)
Sep 5 11:06:01 myhostname5 crontab[10202]: (root) END EDIT (root)
Sep 5 11:10:01 myhostname5 CROND[10554]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Sep 5 11:20:01 myhostname5 CROND[11984]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Sep 5 11:30:02 myhostname5 CROND[12979]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Sep 5 11:40:01 myhostname5 CROND[14476]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Sep 5 11:50:01 myhostname5 CROND[16230]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Sep 5 12:00:01 myhostname5 CROND[17257]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Sep 5 12:01:01 myhostname5 CROND[17441]: (root) CMD (run-parts /etc/cron.hourly)
Sep 5 12:01:01 myhostname5 run-parts(/etc/cron.hourly)[17441]: starting 0anacron
Sep 5 12:01:01 myhostname5 run-parts(/etc/cron.hourly)[17450]: finished 0anacron
Sep 5 12:01:01 myhostname5 run-parts(/etc/cron.hourly)[17441]: starting 0yum-hourly.cron
Sep 5 12:01:01 myhostname5 run-parts(/etc/cron.hourly)[17456]: finished 0yum-hourly.cron
Sep 5 12:10:01 myhostname5 CROND[18756]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Sep 5 12:10:26 myhostname5 crontab[18864]: (root) BEGIN EDIT (root)
Sep 5 12:10:37 myhostname5 crontab[18864]: (root) END EDIT (root)
Sep 5 12:10:45 myhostname5 crontab[18898]: (root) BEGIN EDIT (root)
Sep 5 12:11:12 myhostname5 crontab[18898]: (root) END EDIT (root)
Sep 5 12:13:24 myhostname5 crontab[19828]: (root) BEGIN EDIT (root)
Sep 5 12:13:42 myhostname5 crontab[19828]: (root) END EDIT (root)
Sep 5 12:13:57 myhostname5 crontab[19900]: (root) BEGIN EDIT (root)
Sep 5 12:14:09 myhostname5 crontab[19900]: (root) END EDIT (root)
Sep 5 12:15:16 myhostname5 crontab[20132]: (root) BEGIN EDIT (root)
Sep 5 12:15:28 myhostname5 crontab[20132]: (root) END EDIT (root)
Sep 5 12:16:05 myhostname5 crontab[20190]: (root) BEGIN EDIT (root)
Sep 5 12:16:25 myhostname5 crontab[20190]: (root) END EDIT (root)
监听 crontab 的工作。 /var/.. 中没有符号链接
# ls -ald /var/ /var/spool/ /var/spool/cron/
drwxr-xr-x. 20 root root 4096 Aug 10 19:14 /var/
drwxr-xr-x. 14 root root 4096 May 2 11:42 /var/spool/
drwx------. 2 root root 4096 Jul 8 2014 /var/spool/cron/
# crontab -l
no crontab for root
这里的 strace 输出位于gist.github.com
我不知道这是什么debuginfo
东西
# yum --enablerepo='*' install cronie-debuginfo
Loaded plugins: priorities, product-id, rhnplugin, subscription-manager
This system is receiving updates from RHN Classic or Red Hat Satellite.
47 packages excluded due to repository priority protections
No package cronie-debuginfo available.
Error: Nothing to do
# yum --enablerepo='*' search debuginfo
Loaded plugins: priorities, product-id, rhnplugin, subscription-manager
This system is receiving updates from RHN Classic or Red Hat Satellite.
47 packages excluded due to repository priority protections
============================================================================================== N/S matched: debuginfo ==============================================================================================
percona-xtrabackup-24-debuginfo.x86_64 : Debug information for package percona-xtrabackup-24
riemann-dash-debuginfo.x86_64 : Debug information for package riemann-dash
yum-plugin-auto-update-debug-info.noarch : Yum plugin to enable automatic updates to installed debuginfo packages
zfs-debuginfo.x86_64 : Debug information for package zfs
Name and summary matches only, use "search all" for everything.
答案1
你的错误有点奇怪。要进一步研究它,您可能需要gdb
为 crontab 命令安装 debuginfo 包,以便我们可以看到它正在尝试执行的操作。我的crontab
命令是包的一部分cronie
,正如我通过执行以下操作发现的:
$ rpm -qf $(command -v crontab)
cronie-1.4.12-5.fc22.x86_64
您可以使用以下命令为其安装 debuginfo 包dnf
:
$ sudo dnf --enablerepo='*-debuginfo' install cronie-debuginfo
现在,您可以在 gdb 下运行命令并访问 C 代码中使用的函数名称。我发现你的错误消息发生在glue_strings()
调用时,所以在那里设置一个断点。由于crontab
通常 setuid root,因此您需要 root 才能运行 gdb。 (下面(gdb)
是gdb打印的提示)。
# gdb crontab
(gdb) break glue_strings
启动程序,run
后跟以下参数crontab
:
(gdb) run -e
glue_strings()
您应该看到调用它时传递的参数的转储。
Breakpoint 1, glue_strings (buffer=0x7ffdaa552740 "", buffer_size=4096,
a=0x55c50950e567 "/var/spool/cron", b=0x55c5097154c0 <User> "meuh",
separator=47 '/') at misc.c:110
110 if (buffer_size <= 0)
输入命令c
继续。可能会有多个电话。节目结束前的最后一场是最有趣的。将此输出添加到您的原始帖子中以进行进一步诊断。
上述获取 debuginfo 的命令适用于 Fedora。对于红帽 7.1,请参阅本文这似乎是说列出频道
subscription-manager repos --list | grep -i debug
并启用你想要的,例如
subscription-manager repos --enable=rhel-rs-for-rhel-7-server-fastrack-debug-rpms