Difference between & and nohup &


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Difference between & and nohup &
# 1  
Old 04-16-2015
Difference between & and nohup &

Hi All,

Can anyone please help me understanding what the difference between the below two?

Code:
1. script.sh &
2. nohup script.sh &

# 2  
Old 04-16-2015
executing script.sh with nohup is not linked to your session, making a big difference in the usage as its execution is independent of your connection, you use it for batches you execute mostly with cron...
In other words when you leave and have a job running without nohup normally at your exit prompt you will be reminded with a message of the type " you still have jobs running" having to type exit again only this time you have killed those, running without nohup...
# 3  
Old 04-16-2015
nohup closes and redirects stdin, stdout, and stderr before running the program. This prevents script.sh from accidentally hogging the terminal device -- that's liable to make an ssh session hang instead of quit.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

Nohup with ampersand & process gets disconnected

For years I have spawned shell scripts with nohup and ampersand and they run whether or not I stay logged in. Recently a client told us that we had to set a keep alive timeout on all of our Redhat 7.6 Linux servers. Our sysadmin set the following parameters in the sshd_config file on all of our... (10 Replies)
Discussion started by: gandolf989
10 Replies

2. Shell Programming and Scripting

SFTP Shell Script Get & Delete && Upload & Delete

Hi All, Do you have any sample script, - auto get file from SFTP remote server and delete file in remove server after downloaded. - only download specify filename - auto upload file from local to SFTP remote server and delete local folder file after uploaded - only upload specify filename ... (3 Replies)
Discussion started by: weesiong
3 Replies

3. UNIX for Dummies Questions & Answers

How to get a timestamp when running nohup & from a shell?

Hi, I am running nohup cp & in a shell script. How do I get a timestamp so I can get a timing of how long the copy took? Roughly, the script does something like below: date nohup cp -rp /files/source /files/target & date I am mainly wanting to know how long it took for the... (9 Replies)
Discussion started by: newbie_01
9 Replies

4. Programming

Background (nohup * &) SSH command block possible?

Hello, I am trying to find a way to send several sequential commands via SSH to a remote box in a single command. Thoughts so far: 1) Can I put them into a function and call the function within the ssh command? e.g. ssh <targetserver> $(functionx) No - then it calls the function in... (4 Replies)
Discussion started by: doonan_79
4 Replies

5. UNIX and Linux Applications

nohup and & versus functions

when i have a function definition and function call in my script , i am unable to run my script in background with nohup.. Help me out please..... (3 Replies)
Discussion started by: venugopalsmartb
3 Replies

6. UNIX for Dummies Questions & Answers

nohup & mpiexec problems

Hi everyone - I'm trying to start a run of LAMMPS (which takes an input file) with mpiexec on multiple processors. I want to combine this with nohup so that I can log off the node. I've used the syntax below successfully on one cluster, but it doesn't work on the new one I'm using. Any... (0 Replies)
Discussion started by: erin85
0 Replies

7. Shell Programming and Scripting

PHP read large string & split in multidimensional arrays & assign fieldnames & write into MYSQL

Hi, I hope the title does not scare people to look into this thread but it describes roughly what I'm trying to do. I need a solution in PHP. I'm a programming beginner, so it might be that the approach to solve this, might be easier to solve with an other approach of someone else, so if you... (0 Replies)
Discussion started by: lowmaster
0 Replies

8. Shell Programming and Scripting

Execute Script using nohup and &

Hi all, I have one script test.sh for which I pass two arguments. In the same script I need to submit this script in background using nohup. My script like this and it is working in HP-UX os but not Solaris. #! /bin/sh if then MTR_PID=$$ export MTR_PID echo "test.sh $1 $2... (3 Replies)
Discussion started by: sridhar_423
3 Replies

9. UNIX for Dummies Questions & Answers

Difference between && and -a

I've come stuck when I was making sure the hour of the day was not been two times so that the rest of the script could not be executed. Seems simple enough. I used the -a to join the two conditions together and it would run if the conditions was t/f ( it is only supposed to run if was t/t).... (3 Replies)
Discussion started by: spookyrtd99
3 Replies

10. UNIX Desktop Questions & Answers

what is the difference between Unix & linux, what are the advantages & disadvantages

ehe may i know what are the difference between Unix & Linux, and what are the advantages of having Unix as well as disadvantages of having Unix or if u dun mind i am dumb do pls tell me what are the advantages as well as the disadvantages of having linux as well. thanks (1 Reply)
Discussion started by: cybertechmkteo
1 Replies
Login or Register to Ask a Question