Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to do something fairly simple:

$ ( cd /opt/myprogram && ./myprocess.sh >/dev/null 2>&1 & ; disown $! )
-bash: syntax error near unexpected token `;'

How can I bust out a one-liner to, in a sub-shell, execute a given script from a given folder, nulling the output, and sending it to the background?

share|improve this question
up vote 8 down vote accepted

The problem is that you are using both & and ; together. They are both command terminators, and can not be used at the same time. Here is your example fixed:

( cd /opt/myprogram && ./myprocess.sh >/dev/null 2>&1 & disown )
share|improve this answer

The nohup utility was designed for pretty much what you're looking for:

Usage: nohup COMMAND [ARG]...
  or:  nohup OPTION
Run COMMAND, ignoring hangup signals.

If standard input is a terminal, redirect it from /dev/null.
If standard output is a terminal, append output to 'nohup.out' if possible,
'$HOME/nohup.out' otherwise.
If standard error is a terminal, redirect it to standard output.
To save output to FILE, use 'nohup COMMAND > FILE'.
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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