2

There is a complex command that requires sudo:

sudo command par1 666 /home/me/...

I need to launch it so that it persists after I log off from terminal (SSH). I have discovered that nohup command is supposed to do this.

First problem is, that nohup seems to need sudo:

nohup: failed to open `nohup.out': Permission denied
nohup: failed to open `/home/me/nohup.out': Permission denied

Second thing is, that the latter parameters seem to get lost. What's the proper syntax to run command with all it's parameters asynchronously with administrator rights?

1 Answer 1

4

Your first problem is due to nohup attempting to create a file called nohup.out. It first tries to create this in the current directory, and failing that, will try and create it in your home directory.

From your output, it appears that you do not have write access to either.

Try running it from a directory that you do have write access to (/tmp if you can't find a better directory).

For your second issue, try back quotes around the command and parameters you want to run. E.g.

nohup `sudo command par1 666 /home/me/...`

4
  • Nohup also still seems to leave the command blocking (eg. it doesn't return me back to the console immediatelly). Is that normal? Commented Jun 20, 2014 at 5:27
  • Yes. If you want your prompt back, you need to background the process using an & at the end of the command. Commented Jun 20, 2014 at 5:28
  • The second issue should be non-existing if the first is solved. If you need to quote something, use single or double quotes (depending if there are escape sequences or shell variable substitutions), not backticks which evaluate (similiar to $(...)) to the output of the command they contain. Commented Jun 20, 2014 at 9:54
  • @jofel - Thanks. The man page for nohup on the system I was using (Solaris 10) showed the use of back quotes rather than single or double quotes in the examples, so that is why I suggested back quotes. Commented Jun 21, 2014 at 3:55

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.