cron的问题 [英] Issues with cron

查看:122
本文介绍了cron的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真的卡住了。我在许多机器上使用cron,但我根本不能让它在Ubuntu服务器上工作。我试过了一切,我可以考虑在周末,我很困惑。我希望有人可以帮助我。

I'm really stuck. I've used cron on many machines, but I simply can not get it to work on an Ubuntu server. I've tried everything I can think over the weekend and I'm baffled. I'm hoping someone can help me out.

我可以通过 pgrep cron 验证cron是否正在运行。但是, pgrep crond 不返回任何内容。我试图用cron运行一个简单的shell脚本(test.sh):

I can verify that cron is running via pgrep cron. However, pgrep crond returns nothing. I am trying to run a simple shell script (test.sh) with cron:

#!/bin/sh
/usr/bin/touch /home/jarvis/test.txt

$ c> chmod + x 在shell脚本和我的crontab看起来像这样:

I have run chmod +x on the shell script and my crontab looks like this:

01 * * * * /home/jarvis/test.sh

我也有一行新行

推荐答案

尝试将所有输出重定向到一个文件,并查看是否有任何错误消息可以帮助您诊断问题,即

Try redirecting all output to a file and see if there are any error messages that can help you diagnose the problme, i.e.

01 * * * * /home/jarvis/test.sh > /tmp/jarvis_test.log 2>&1

此外,如果您创建了Windows环境,不要忘记 dos2unix filename

Also, if you created any of those files from a windows environment, don't forget dos2unix filename

编辑
我的观点是,你不知道你的脚本在crontab环境中做什么,除非你看到它是否正在输出一个错误消息。错误消息也转到本地crontab用户的电子邮件,所以尝试 mail (作为同一个用户),看看你有一堆来自你的crontab的消息。

edit My point is that you won't know for what your script is doing in the crontab environment unless you see if it is outputing an error message. Error messages also go to local crontab user's email, so try mail (as the same user) and see if you have a bunch of messages from your crontab.

pgrep crond 返回没有什么听起来像问题,但我不是系统管理员。也许您想举报此问题,并要求管理员转到 http://serverfault.com/

pgrep crond returning nothing sounds like the problem, but I'm not a sysadmin. Maybe you want to flag this and ask for moderator to move to http://serverfault.com/

我希望这有助于。

这篇关于cron的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆