Reputation: 43
I am trying to to run a cronjob of a script on an EC2 Instance but it's simply not working The way I am running it right now is
15 * * * * root /home/ec2-user s3_upload.sh TestBucket
I wrote this when I did crontab -e
Right now I am in this directory /home/ec2-user/ so I don't know if maybe that has something to do with why it's not running.
I just don't understand this whole cron thing and how permissions work.
Any help is greatly appreciated!
Upvotes: 0
Views: 2098
Reputation: 123470
You can't specify a username in a user's crontab, only in /etc/crontab
.
You can't specify a directory in any form of crontab. To change directory, use cd.
The environment is not the same. If you e.g. set PATH in .bashrc
, these will not be automatically included, so it's safest to use full paths.
As root (assuming you want to run this as root and not ec2-user or something), run crontab -e
and add
15 * * * * cd /home/ec2-user && /full/path/to/s3_upload.sh TestBucket
Make sure you can copy-paste the command in a root terminal and get it working, and read root's mail afterwards to see the command's output with possible error messages. If it still doesn't work, make sure you have these errors available.
Upvotes: 1