【问题标题】:My Cron is not running我的 Cron 没有运行
【发布时间】:2015-06-15 06:24:58
【问题描述】:

我有一个设置为定期运行的 cronjob 列表。 在这里阅读并尝试了这个建议后:

https://stackoverflow.com/a/22744360/1478789

我仍然无法弄清楚为什么我的 cron 作业没有运行。

当我尝试使用这个简单的命令时:

* * * * * /bin/echo "cron works" >> /home/user/somefile.log

它不会将任何文本附加到预期的文件中。

所以,我尝试通过执行以下命令“手动”执行此操作:

user@machine:~$ echo "Random text" >> /home/user/somefile.log

它将一些文本附加到文件中。

最后,当我发出以下命令时:

user@machine:~$ grep CRON /var/log/syslog

它根本不打印任何东西

顺便说一下,我编辑了我的 cron

user@machine:~$ sudo EDITOR=nano crontab -e

如果,我用这个:

user@machine:~$ EDITOR=nano crontab -e (without sudo)

我收到以下消息:

no crontab for user - using an empty one
Error reading /home/user/.nano_history: permission denied
Press Enter to continue starting nano

谁能帮我解决这个问题,谢谢。

【问题讨论】:

  • 你不应该碰sudo,你的主目录很容易弄乱权限,这可能是~/.nano_history错误的原因。
  • @o11c 感谢您的建议,让我先检查一下。
  • askubuntu.com 可能是解决这类问题的更好地方。
  • 这个问题似乎是off topic
  • @o11c 感谢您的提示。你是对的,.nano_history 文件有问题。

标签: linux bash cron crontab ubuntu-14.04


【解决方案1】:

cron 正在运行吗?

$ps ax | grep cron
1236 ?        Ss     0:00 cron

如果不检查,

$ sudo /etc/init.d/cron.status
cron start/running, process 1236

如果你的没有运行,它会说: cron stop/waiting

尝试使用

$sudo /etc/init.d/cron start

-- hth

基思

编辑: 糟糕的是,我在重新阅读您的帖子后看到您的 cron 正在运行……嗯,我会进一步研究这个问题,因为我记得几个月前遇到过类似的问题,我也在笔记本电脑上运行 ubuntu 14.04。 对不起...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-03
    • 2012-08-18
    • 2014-01-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多