bashbackgroundmplayer

Run mplayer command in background replace &1 with 1


The formal way to run mplayer in background.

mplayer some.mkv </dev/null >/dev/null 2>&1 &
[3]9536

[3]9536 means pid of the mplayer command is 9536.
If i replace &1 with 1 for the above command:

mplayer some.mkv </dev/null >/dev/null 2>1 &
[4] 9590
[3]   Done                    mplayer some.mkv < /dev/null > /dev/null 2> 1

Why got the extra output here?

[3]   Done                    mplayer some.mkv < /dev/null > /dev/null 2> 1

Solution

  • It's not related to your change. This happened because your previous mplayer instance exited in the mean time. Here's another example:

    $ sleep 1 &
    [1] 18155                                   # Sleep #1 started in background
    $ sleep 1 &
    [2] 18163                                   # Sleep #2 started in background
    [1]   Done                    sleep 1       # Sleep #1 finished because it's been a second
    

    Replacing 2>&1 with 2>1 makes mplayer status and errors go to a file named 1 in the current directory. I don't know why you would do such a thing, but bash is happy to oblige.