0

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?

2

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 the nohup.out file already? – the_velour_fog Aug 19 '16 at 10:18
  • It prevents the output of nohup: ignoring input and appending output to ‘nohup.out’ – Lambert Aug 19 '16 at 10:42
  • Adding this to .bashrc was indeed the solution, and works like a charm. – Gamer1120 Aug 19 '16 at 11:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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