Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This one has been bugging me for a while: I want to use the marvelous GNU watch command to run a few custom aliases and functions that are defined in my .bashrc, but it is never able to run anything except bash built-ins or binaries.

watch -d foo

The output is always: foo: command not found

How can I make it inherit my environment or use the .bashrc?

Thank you.

share|improve this question
What is foo? A shell script? An alias? What if you run that watch command from your prompt? – lorenzog Mar 17 '10 at 23:18
As I mentioned, foo can be a custom alias or a bash function, not just a simple call to a binary. – Artem Russakovskii Mar 17 '10 at 23:34
Here's an example of a bash function: x () { xmllint -format $* ;} – Artem Russakovskii Mar 17 '10 at 23:35
up vote 4 down vote accepted

Do something like this watch bash -i -c 'alias -p' this should call bash, load your settings and then run whatever command you have after the -c

share|improve this answer
Brilliant - that worked like a charm. – Artem Russakovskii Mar 18 '10 at 5:19

From man watch:

Note that command is given to "sh -c"

So it's not going to see your Bash aliases and functions.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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