crontab 在 Linux 中不起作用
我的 Linux 版本是 red hat enterprise linux server release 5.3 tikanga
我已安排 crontab 如下所示
1 * * * * /usr/testjob.sh 2>&1 >> /usr/result.txt
crontab 作业未按计划时间运行...
请建议..
My Linux version is red hat enterprise linux server release 5.3 tikanga
i have schedule crontab as below
1 * * * * /usr/testjob.sh 2>&1 >> /usr/result.txt
crontab job not running on scheduled time...
Please suggest..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
正如 +Shawn Chin 所说,如果您只想运行一次命令,那么 at 命令是您的朋友。
如果您想重复运行命令,那么使用 cron 框架是正确的。可以使用以下命令获取解释 crontab 字段的手册页:
您似乎位于印度时区 (IST)。您可能必须在 crontab 中指定它。例如,使用“crontab -e”命令(要保存并退出,请键入“ESC-wq”,因为编辑器默认为 VI):
请注意,“2>&1”应放在“之后” >>> /usr/result.txt',而不是之前。
As said by +Shawn Chin, if you want to run your command only once, the at command is your friend.
If you want to run your command repeatedly, then you are right to use the cron framework. The manual page explaining the fields of the crontab may be obtained with the following command:
You appear to be in an Indian time-zone (IST). You may have to specify that into the crontab. For instance, using the 'crontab -e' command (to save and quit, type 'ESC-wq', as the editor is VI by default):
Note that '2>&1' should be placed AFTER '>> /usr/result.txt', not before.
只是提一下并确保
just to mention it and make sure
首先尝试这个。
那么你可能每分钟都会收到一封邮件。检查错误输出。
有时,这可能是由于您的默认 shell 只是 sh 而不是 bash 造成的。
所以,也许“>>”不支持。
当你想写入/usr时,你应该检查你是否有/usr权限。
Try this at first.
Then you may received a mail for every minutes. Check the error output.
Sometimes, it may caused by your default shell is just sh instead of bash.
So, maybe ">>" is not supported.
You should check do you have /usr permission when you want to write into it.