1

If I want to run a script in background, for example a.sh, should I run

./a.sh &

or should I put it in a subshell then background it?

(./a.sh) &

I test both and don't see difference, both works, can anyone tell me when should I use ()& or just &? what's the real difference and cautious?

chengdol
  • 155
  • 1
  • 6
  • Possible duplicate of: [putting subshell in background vs putting command in background](https://unix.stackexchange.com/questions/286971/putting-subshell-in-background-vs-putting-command-in-background) – ozzy Jun 08 '19 at 07:22
  • 1
    You should use the 1st. The 2nd just gives the spurious impression that it's doing something special, while in fact it isn't. Do not confuse it with `(./a.sh &)` which really is [different](https://unix.stackexchange.com/questions/491157). –  Jun 08 '19 at 08:20

0 Answers0