Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

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/...`

share|improve this answer
    
Nohup also still seems to leave the command blocking (eg. it doesn't return me back to the console immediatelly). Is that normal? –  Tomáš Zato Jun 20 at 5:27
    
Yes. If you want your prompt back, you need to background the process using an & at the end of the command. –  Warwick Jun 20 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. –  jofel Jun 20 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. –  Warwick Jun 21 at 3:55

Your Answer

 
discard

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.