不能得到的cron工作在Amazon EC2上? [英] Cannot get cron to work on Amazon EC2?

查看:214
本文介绍了不能得到的cron工作在Amazon EC2上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经花了两天时间想明白,为什么我不能得到的cron工作在我的Ubuntu EC2实例。我读过的文档。任何人都可以帮忙吗?我想要的是得到一个工作的cronjob。

I've spent two days trying to understand why I can not get cron to work on my Ubuntu EC2 instance. I've read the documentation. Can anyone help? All I want is to get a working cronjob.

我使用的是简单的wget命令测试的cron。我已验证该手动工作通过命令行:

I am using a simple wget command to test cron. I have verified that this works manually from the command line:

的/ usr / bin中/ wget的-O /家庭/ Ubuntu的/备份/ testfile将http://www.nytimes.com/

我的crontab文件看起来是这样的:

My crontab file looks like this:

02 * * * *的/ usr / bin中/ wget的-O /家庭/ Ubuntu的/备份/ testfile的http://www.nytimes.com/

我的命令之间单个空格,我有下面的命令一个空行。我也试图从制度层面执行此命令须藤的crontab -e 。它仍然无法正常工作。

I have single spaces between the commands and I have a blank line below the command. I've also tried to execute this command from the system level sudo crontab -e. It still doesn't work.

cron守护程序正在运行:

The cron daemon is running:

ps aux | grep crond                                                                                                                   
ubuntu    2526  0.0  0.1   8096   928 pts/4    S+   10:37   0:00 grep crond

本的cronjob似乎运行:

The cronjob appear to be running:

$ crontab -l
02 * * * * /usr/bin/wget -O /home/ubuntu/backups/testfile http://www.nytimes.com/

没有人有任何建议或可能的解决方案?

Does anyone have any advice or possible solutions?

感谢您的时间。

推荐答案

克朗可以在亚马逊的Linux服务器上运行,就像在任何其他的Linux服务器。

Cron can be run in Amazon-based linux server just like in any other linux server.

  1. 在登录使用SSH控制台。
  2. 运行的crontab -e 在命令行上。
  3. 您现在里面的当前用户的crontab中的vi编辑器(默认情况下是控制台的用户,用root权限)
  4. 要测试的cron,添加以下行: * * * * *的/ usr / bin中/正常运行时间和GT;的/ tmp /运行时间
  5. 现在,保存文件并退出VI(preSS ZZ或:WQ)。
  6. 在一两分钟后,检查正常运行时间的文件在/ tmp目录(猫的/ tmp /运行时间)创建的。
  7. 在它与在命令行中键入运行时间命令当前系统正常运行时间进行比较。
  1. Login to console with SSH.
  2. Run crontab -e on the command line.
  3. You are now inside a vi editor of the crontab of the current user (which is by default the console user, with root permissions)
  4. To test cron, add the following line: * * * * * /usr/bin/uptime > /tmp/uptime
  5. Now save the file and exit vi (press ZZ or :wq).
  6. After a minute or two, check that the uptime file was created in /tmp (cat /tmp/uptime).
  7. Compare it with the current system uptime by typing the uptime command on the command line.

上面的方案成功地与亚马逊的Linux O / S安装在服务器上,但它应该在其他Linux系统正常工作。这会修改当前用户的crontab中,不接触系统的crontab中,并不需要在crontab条目中的用户,因为你正在运行在你自己的用户的东西。更方便,更安全!

The scenario above worked successfully on a server with the Amazon Linux O/S installed, but it should work on other linux boxes as well. This modifies the crontab of the current user, without touching the system's crontabs and doesn't require the user inside the crontab entry, since you are running things under your own user. Easier, and safer!

这篇关于不能得到的cron工作在Amazon EC2上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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