Executing a script with nohup


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Executing a script with nohup
# 1  
Old 05-21-2013
Executing a script with nohup

Hi,

Is there any way to achieve that my script should always execute like:
Code:
 nohup ./scriptname >nohup.out &

even if i execute
Code:
 ./scriptname

, it should be converted to
Code:
 nohup ./scriptname >nohup.out &

and then execute.

How i can achieve this?

Thanks in advance
# 2  
Old 05-21-2013
If you need the functionality of nohup, you could set a trap for SIGHUP to ignore it and ensure required redirections.
This User Gave Thanks to elixir_sinari For This Post:
# 3  
Old 05-22-2013
Quote:
Originally Posted by elixir_sinari
If you need the functionality of nohup, you could set a trap for SIGHUP to ignore it and ensure required redirections.
Hi, Could you please explain/show some related examples?

Thanks
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Saving nohup output to a file other than nohup.out

Shell : bash OS : Oracle Linux 6.4 I want to save the ouput of a nohup command to file other than nohup.out . Below are my 3 attempts. For both Attempt1 and Attempt2 , the redirection logs the output correctly to the output file. But I get the error "ignoring input and redirecting stderr to... (7 Replies)
Discussion started by: kraljic
7 Replies

2. UNIX for Dummies Questions & Answers

Test if script was ran w/ nohup

I want to test if script.sh is being run with nohup ... but $0 does not contain nohup part... purpose: script.sh should only be ran with nohup if user forgets nohup then it should echo "run with nohup" && exit....... (2 Replies)
Discussion started by: holyearth
2 Replies

3. Shell Programming and Scripting

shell script not working with nohup

Hello, I am trying to run a shell script with the nohup command. The shell script takes an array of files, runs a python program on each file in a loop, and appends the output to a file. This works fine on the server, but if I try to use the nohup command it does not work. --- #!/bin/sh... (10 Replies)
Discussion started by: ricitron
10 Replies

4. UNIX for Dummies Questions & Answers

nohup - sub job in script not executing until I exit

My job is launched using this command: I'm at home and having VPN drops so I used nohup and background. nohup perf_mon -c rating_4_multi,cfg & The main script is PID 26119, and the sub task under it is 26118 which is not running - just sits there. 26119 runs forever but nothing else runs. I... (2 Replies)
Discussion started by: ido1957
2 Replies

5. AIX

Query on running script with nohup

Hi, I'm trying to run database restore script with the nohup command as it will run for long hours since if I run it normally, the putty session will become inactive and the restore gets terminated. The command I use is nohup db2 -tvf FBR_NODE0000.scr -z FBR_NODE0000.log & But the problem is... (2 Replies)
Discussion started by: vkcool.17
2 Replies

6. Shell Programming and Scripting

inbuilt nohup logic into the script

Hi All, I know one way to use nohup as below: nohup myscript.ksh However, just wanted to know is there any way to write the nohup logic directly into the script so that we can execute the script without need to specify the nohup like this: myscript.ksh Many Thanks in advance. (7 Replies)
Discussion started by: jal_capri
7 Replies

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

8. Shell Programming and Scripting

nohup command in the script....

I want to know how to use a nohup command in the script........ I have to run following command nohup /tmp/app/statuscheck.sh & After typing this command I will type ctrl D to come to the prompt and the that command will run in backround. Even after pressing & the command is not... (3 Replies)
Discussion started by: jayaramanit
3 Replies

9. Shell Programming and Scripting

nohup command in a script.......

I want to know how to use a nohup command in the script........ I have to run following command nohup /tmp/app/statuscheck.sh & After typing this command I will type ctrl D to come to the prompt and the that command will run in backround. I want to include that command in a... (2 Replies)
Discussion started by: jayaramanit
2 Replies

10. Shell Programming and Scripting

Problem executing nohup

I am trying to submit background jobs using the nohup command on a client system where my session is running under a "master shell" (BASH). If I try to nohup the actual job (ie: nohup MYJOB.BAT > MYJOB.LOG 2>&1 &) the command will fail with a return code of 126 and a "permission denied" message.... (0 Replies)
Discussion started by: christyw
0 Replies
Login or Register to Ask a Question