简体   繁体   中英

Setting up cron jobs on AWS EC2 via crontab

i am trying to set up a cron job on one of my EC2 instances on AWS via crontab. Doing following steps:

  • Log into my server via ssh (with user ec2-user ) and running crontab -l to check if any crontabs are running for existing users. There isn't any.
  • Run nano crontab -e to create a new crontab file for ec2-user . File created and saved. When running crontab -l getting output no crontab file for ec2-user and obviously cron is not running.

When running ps -ef | grep cron | grep -v grep cron ps -ef | grep cron | grep -v grep cron ps -ef | grep cron | grep -v grep cron seem to be running ok. Output is:

root 2460 1 0 13:12 ? 00:00:00 crond

I have had a look into a few resource on the web:

But still not working. Seems like something is wrong when creating a crontab file for ec2-user but i cannot seem to figure out what is wrong.

It is best to add cron file (any name without dot, eg my-cron-job) the content is just the cron command make sure there is \\r in the end of the command add this file under /etc/cron.d permissions 644

This approach is used in all automations in Ansible / Puppet

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM