无法让cron在Amazon EC2上工作? [英] Cannot get cron to work on Amazon EC2?

查看:198
本文介绍了无法让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 / home / ubuntu / backups / testfile http ://www.nytimes.com/

我的crontab文件如下所示:

My crontab file looks like this:

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

我在命令之间有单个空格,我在命令下面有一个空行。我也试图从系统级别执行此命令 sudo 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?

感谢您的时间。

推荐答案

Cron可以在基于Amazon的linux服务器上运行,就像在任何其他linux服务器中一样。

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


  1. SSH。

  2. 在命令行上运行 crontab -e 一个vi编辑器crontab的当前用户(这是默认情况下控制台用户,具有root权限)

  3. 要测试cron,添加以下行: * * * * * / usr / bin / uptime> / tmp / uptime

  4. 现在保存文件并退出vi(按ZZ或:wq)。

  5. 分钟或两分钟,请检查是否在/ tmp( cat / tmp / uptime )中创建了正常运行时间文件。


  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.

在命令行中输入 uptime 上面的方案在安装了Amazon 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天全站免登陆