Adam
Adam

Reputation: 36703

Cannot get nohup, open_init_pty and sudo to work together

I'm struggling to combine nohup, open_init_pty and sudo in a one-liner. Something like this:

nohup open_init_pty sudo bash -c "command1;command2"

My requirements are a little strange:

I've tried to narrow down the problem using different combinations:

# works OK, output in nohup.out
nohup sudo bash -c "echo hello"

# works OK, hello output to console
open_init_pty sudo bash -c "echo hello"

# doesn't work
nohup open_init_pty sudo bash -c "echo hello"

What am I doing wrong??

Upvotes: 2

Views: 475

Answers (1)

John Zwinck
John Zwinck

Reputation: 249293

How about doing it without nohup? You can start a subshell like this:

(open_init_pty sudo bash -c "echo hello")

I sometimes do this with a & on the end, but your examples didn't run in the background. Anyway, this may accomplish your goal of not having the job terminate if the parent shell exits.

Upvotes: 1

Related Questions