Cannot get cron to work on Amazon EC2?

后端 未结 7 1522
南旧
南旧 2020-12-09 09:49

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 wor

7条回答
  •  时光说笑
    2020-12-09 10:07

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

    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 Esc and enter :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.

    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!

提交回复
热议问题