I can run the command aws --version in a script and in the cli. But if I put this command into a crontab it does not work.


50 12 * * * aws --version > ~/yolo.swag


/bin/sh: 1: aws: not found

The aws command is in a bash script. And I get the same error message when I run the script in cron. How can I get the script to run the command fine ?

  • can you paste also content of your cron ? crontab -l ? Most probably you should put in your cron something like: SHELL=/bin/bash */1 * * * * aws --version
    – klerk
    Aug 3, 2015 at 12:51
  • I have added my crontab. I think the path to the AWS command is as follows: /usr/local/bin/aws . How do I do that ? Remember that this is not bash, its a separate appliaction.
    – Narayana
    Aug 3, 2015 at 12:56

3 Answers 3


You need to specify the full path to the aws executable:

50 12 * * * /usr/local/bin/aws --version > ~/yolo.swag
  • This worked fine. I have updated my question though. As the aws command I am actually running needs to work within my bash script.
    – Narayana
    Aug 3, 2015 at 13:07
  • I have done so. How can I set the aws path globally ?
    – Narayana
    Aug 3, 2015 at 13:13
  • These tips also might help you to understand cron behavior: krisjordan.com/essays/timesaving-crontab-tips
    – klerk
    Aug 3, 2015 at 13:18
  • The path is already absolute (/usr/local/bin/aws) if you to be able to call it just with 'aws' put it in your root PATH variable.
    – Baazigar
    Aug 3, 2015 at 15:38
  • This worked fine........! Aug 13, 2020 at 15:08

Put this code before your command line to be executed into crontab -e


The problem is that the login environment is not the same as the one in which cron runs. So basically the environment is not set i.e. all your rc files, alias, user-defined functions are not present to cron at runtime.

One solution is to source the profile/rc files that sets the required paths and aliases.

 * 5 * * * * $HOME/.profile; $HOME/.bashrc ; <your command>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .