即使cron进程正在运行,Cronjob也无法正常工作

时间:2019-10-25 08:45:25

标签: bash cron debian

我已经配置了一个非常简单的cron作业,但是无法正常工作。

$ crontab -e

* * * * * /usr/bin/env > /home/myid/env
* * * * * /bin/echo 'hi' > /home/myid/HI

以上作业根本不起作用。 / usr / bin / env和/ bin / echo的路径正确。


我可以看到cron正在作为一个进程运行,看来root可以执行cron作业。

$ ps aux | grep cron

root      2771  0.0  0.1   2316   860 ?        Ss   07:54   0:00 /usr/sbin/cron
myid     12232  0.0  0.1   2040   632 pts/1    S+   08:17   0:00 grep cron

$ tail -24 / var / log / syslog

Oct 25 08:01:08 localhost crontab[5224]: (myid) BEGIN EDIT (myid)
Oct 25 08:01:44 localhost init: Id "1" respawning too fast: disabled for 5 minutes
Oct 25 08:03:37 localhost crontab[5224]: (myid) END EDIT (myid)
Oct 25 08:05:01 localhost /USR/SBIN/CRON[7008]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Oct 25 08:07:31 localhost sendmail[9090]: My unqualified host name (localhost) unknown; sleeping for retry
Oct 25 08:07:35 localhost init: Id "1" respawning too fast: disabled for 5 minutes
Oct 25 08:08:01 localhost /usr/sbin/cron[2771]: (*system*sendmail) RELOAD (/etc/cron.d/sendmail)
Oct 25 08:08:31 localhost sendmail[9090]: unable to qualify my own domain name (localhost) -- using short name
Oct 25 08:08:31 localhost sendmail[9090]: alias database /etc/mail/aliases rebuilt by root
Oct 25 08:08:31 localhost sendmail[9090]: /etc/mail/aliases: 12 aliases, longest 10 bytes, 134 bytes total
Oct 25 08:08:32 localhost sm-mta[9484]: My unqualified host name (localhost) unknown; sleeping for retry
Oct 25 08:08:34 localhost sm-msp-queue[9501]: My unqualified host name (localhost) unknown; sleeping for retry
Oct 25 08:09:32 localhost sm-mta[9484]: unable to qualify my own domain name (localhost) -- using short name
Oct 25 08:09:32 localhost sm-mta[9732]: starting daemon (8.14.4): SMTP+queueing@00:10:00
Oct 25 08:09:34 localhost sm-msp-queue[9501]: unable to qualify my own domain name (localhost) -- using short name
Oct 25 08:13:26 localhost init: Id "1" respawning too fast: disabled for 5 minutes
Oct 25 08:14:30 localhost crontab[11351]: (myid) BEGIN EDIT (myid)
Oct 25 08:15:01 localhost /USR/SBIN/CRON[11524]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Oct 25 08:16:21 localhost crontab[11351]: (myid) END EDIT (myid)
Oct 25 08:17:01 localhost /USR/SBIN/CRON[12193]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Oct 25 08:19:17 localhost init: Id "1" respawning too fast: disabled for 5 minutes
Oct 25 08:20:01 localhost /USR/SBIN/CRON[13206]: (smmsp) CMD (test -x /etc/init.d/sendmail && /usr/share/sendmail/sendmail cron-msp)
Oct 25 08:20:02 localhost sm-msp-queue[13222]: My unqualified host name (localhost) unknown; sleeping for retry
Oct 25 08:21:02 localhost sm-msp-queue[13222]: unable to qualify my own domain name (localhost) -- using short name

$服务计划状态

[ ok ] cron is running.

在crontab开头指定SHELL变量也不是解决方案。

SHELL=/bin/bash
* * * * * /usr/bin/env > /home/myid/env
* * * * * /bin/echo 'hi' > /home/myid/HI

我真的不知道为什么它不起作用。有什么建议吗?

0 个答案:

没有答案