1
[root@~]# ./file.sh & 

I don't know if $! will terminate if I just log out immediately?

1

2 Answers 2

2

disown the job and it won't. If it's the only thing running in the background, you'd do disown %1. Otherwise it would be the job number given in square brackets when you start the job.

3
  • Who is right,you or @Kyle Brandt? Commented Mar 12, 2010 at 14:05
  • 2
    They're both right. There's more to it than you understand. See also: serverfault.com/questions/115999/… disown forks the process from the shell, so it won't be sent a SIGHUP on exit even if huponexit is on. Commented Mar 12, 2010 at 14:15
  • I am right times infinity squared + 2. You want disown the job if you can. Ideally I would recommend that you run the job with screen or maybe nohup. Commented Mar 12, 2010 at 14:16
0

I'm not sure the exact answer to this question.

I do know that to detach from the console requires more than just redirecting to /dev/null. You need to consider using setsid as well as redirecting 1>/dev/null and 2>/dev/null.

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.