2

I've got a cronjob that won't work. Well, I can't seem to get any of my cronjobs to work.

here is my entry in /etc/crontab

* * * * * /usr/bin/Rscript /home/myRScript.R

Executing this script via command line (/usr/bin/Rscript /home/myRScript.R) runs fine. The script is executable (chmod 775).

I've even tried something simple like:

* * * * * env > /tmp/env.output 

I have the script running fine on my home desktop. But am attempting to migrate the same code to an Amazon EC2 instance and it won't run. I'm at a loss for what to do next.

I've pretty much read through: https://askubuntu.com/questions/23009/reasons-why-crontab-does-not-work

And nothing seems to work.

Community
  • 1
  • 1
imgschatz
  • 95
  • 2
  • 9
  • Followed the example here: http://stackoverflow.com/questions/10472173/cannot-get-cron-to-work-on-amazon-ec2 answered by Druvision. I was using /etc/crontab and for whatever reason that never worked. Using crontab -e worked. – imgschatz May 13 '14 at 01:50

2 Answers2

4

Most likely the cause of this is that some versions of cron (including the amz-linux) require that there is an newline at the end of the crontab file. Please add a blank line at the end of the file.

bwight
  • 3,300
  • 17
  • 21
2

The OP mentions Ubuntu on ec2, but thought I'd post my answer for the same question when using Amazon's linux distro on ec2: after trying all kinds of things for cron all I needed was:
sudo service crond start
crontab -e
This allowed me to set a cron job as "ec2-user" without specifying anything other than the cron job itself. For example:
0 12 * * * python3 /home/ec2-user/example.py
I also posted this here.

Community
  • 1
  • 1
j3py
  • 1,119
  • 10
  • 22