Cannot get cron to work on Amazon EC2?

后端 未结 7 1524
南旧
南旧 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:17

    On some AWS Ubuntu EC2 machines, cron jobs cannot be edited or made to run by using crontab -e or even sudo crontab -e (for whatever reason). I was able to get cron jobs working by:

    1. touch /home/ubuntu/crontest.log to create a log file
    2. sudo vim /etc/crontab which edits the system-wide crontab
    3. add your own cron job on the second to last line using the root user, such as * * * * * root date && echo 'It works!'>> /home/ubuntu/crontest.log 2>&1 which dumps stdout and stderr into the logfile you created in step 1
    4. Verify it is working by waiting 1 minute and then cat /home/ubuntu/crontest.log to see the output of the cron job
    0 讨论(0)
提交回复
热议问题