Possible Duplicate:
My cron tasks report command not found

I am trying to run a bash script


export AWS_CLOUDWATCH_URL=https://monitoring.amazonaws.com

# get ec2 instance id
instanceid=`wget -q -O -`

memtotal=`free -m | grep 'Mem' | tr -s ' ' | cut -d ' ' -f 2`
memfree=`free -m | grep 'buffers/cache' | tr -s ' ' | cut -d ' ' -f 4`
let "memused=100-memfree*100/memtotal"

mon-put-data --metric-name "FreeMemoryMBytes" --namespace "System/Linux" --dimensions "InstanceId=$instanceid" --value "$memfree" --u$

mon-put-data --metric-name "UsedMemoryPercent" --namespace "System/Linux" --dimensions "InstanceId=$instanceid" --value "$memused" --$

I have added this bash script in the cron but when I checked the cron it says command not found thats "mon-put-data"

when I just type the commands it runs fine. Whats the problem

marked as duplicate by Iain, Scott Pack, Rob Moir, Chris S, MDMarra Jan 11 '12 at 15:15

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


It is likely that the mon-put-data command is not in a standard path. From the terminal, you can check this by typing which mon-put-data, then try to use the full path in the script.

This is because a bash script launched from cron won't read your .bashrc or .bash_profile, which may override the default path.


Try to add the full path to mon-put-data. From your command line you can find this with:

which mon-put-data


The problem is that the user that executes the script does not have the same environment (specifically, not the same PATH) that you do.

Additionally, I would suggest you use $(command) instead of `command`, as the latter is deprecated and can cause problems with quoting.

  • The obsolescence of the backticks is worth mentioning indeed... – ℝaphink Jan 11 '12 at 10:18

Are you using the same shell? Check. You might be using csh in terminal and the script might use bash.

  • the question has a 'bash' tag – glenn jackman Jan 11 '12 at 11:56

Not the answer you're looking for? Browse other questions tagged or ask your own question.