I'm trying to setup a script in my .bashrc which would create an alias that makes it possible to run a command in the background and ignores output. It should be possible for this command to have multiple arguments, for example "java -jar MyJar.jar". So far I have tried: alias back='nohup "$1" > /dev/null &' But when I test it using for example back sh path/to/intellij/bin/idea.sh my console output is like this: nohup: failed to run command ‘’: No such file or directory And whenever an error happens, it's also logged, which is what I wanted to avoid. Am I taking the wrong approach here or what is going on?
1 Answer
You will need to use a function instead of an alias like:
function back() {
nohup "$@" &> /dev/null &
}
-
What does the
&> /dev/null
do here? doesn't the nohup command itself capture all the output into thenohup.out
file already? Aug 19, 2016 at 10:18 -
It prevents the output of
nohup: ignoring input and appending output to ‘nohup.out’
– LambertAug 19, 2016 at 10:42 -
Adding this to .bashrc was indeed the solution, and works like a charm. Aug 19, 2016 at 11:24