Using aliases with nohup

For bash: Try doing nohup 'your_alias'. It works for me. I don't know why back quote is not shown. Put your alias within back quotes.


With bash, you can invoke a subshell interactively using the -i option. This will source your .bashrc as well as enable the expand_aliases shell option. Granted, this will only work if your alias is defined in your .bashrc which is the convention.

Bash manpage:

If the -i option is present, the shell is interactive.

expand_aliases: If set, aliases are expanded as described above under ALIASES. This option is enabled by default for interactive shells.

When an interactive shell that is not a login shell is started, bash reads and executes commands from /etc/bash.bashrc and ~/.bashrc, if these files exist.


$ nohup bash -ci 'sayHello'

Because the shell doesn't pass aliases on to child processes (except when you use $() or ``).

$ alias sayHello='/bin/echo "Hello world!"'

Now an alias is known in this shell process, which is fine but only works in this one shell process.

$ sayHello 

Hello world!

Since you said "sayHello" in the same shell it worked.

$ nohup sayHello

Here, a program "nohup" is being started as a child process. Therefore, it will not receive the aliases. Then it starts the child process "sayHello" - which isn't found.

For your specific problem, it's best to make the new "perl" and "python" look like the normal ones as much as possible. I'd suggest to set the search path.

In your ~/.bash_profile add

export PATH="/my/shiny/interpreters/bin:${PATH}"

Then re-login.

Since this is an environment variable, it will be passed to all the child processes, be they shells or not - it should now work very often.