run shell script under nohup directly [solved]


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting run shell script under nohup directly [solved]
# 1  
Old 03-15-2012
run shell script under nohup directly [solved]

Hi,

i am not able to run the loop in nohup directly.

Code:
nohup 'for i in $(seq 10); do echo $i;./mscript.sh $i; done'

can some one help me how to run this directly in nohup?

---------- Post updated 03-15-12 at 12:20 AM ---------- Previous update was 03-14-12 at 11:59 PM ----------

From man page of 'sh' i got this:
-c Read commands from the command_string operand instead of from the
standard input. Special parameter 0 will be set from the command_name operand
and the positional parameters ($1, $2, etc.) set from the remaining argument operands.

Now I got it.
Code:
nohup sh -c 'for i in $(seq 10); do echo $i;./mscript.sh $i; done' &

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Nohup apending data each time i run script

I have a problem here. i am running my script in nohup but if i run it 2 or three time , in my output i see it is giving me old data as well, in-spite i delete nohup.out file. i tried to look a lot from where the old data is coming. can some one tell me how the old data is also coming again and... (11 Replies)
Discussion started by: mirwasim
11 Replies

2. UNIX for Advanced & Expert Users

Need shell script for SMS via telnet command to SMSC directly

I am not very much familiar with telnet based scripting so I would need your help to directly submitting sms as deliver_sm or submit_sm msg to SMSC (IP & system_id and password are already known). So, need your help to provide such script. I previously used such script but my harddisk crashed and... (0 Replies)
Discussion started by: wasay
0 Replies

3. Shell Programming and Scripting

Nohup inside shell script

Hi, I want to run another script inside shelll script in nohup mode. let explain. under the same folder ,I have two scripts scrone.sh scrtwo.sh In scrone.sh if then nohup ./scrtwo.sh & echo " Script two has been run correctly" else echo " Exiting from the script" fi If... (3 Replies)
Discussion started by: ckchelladurai
3 Replies

4. UNIX for Advanced & Expert Users

[Solved] Using nohup

Hi, on AIX 6.1 Will this work : mycommande & Or it should be : nohup mycommande & It seems that nohup mycommande & (5 Replies)
Discussion started by: big123456
5 Replies

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

6. Shell Programming and Scripting

Run perl command in script[solved]

Hi all, When I put the Perl command in a script, I got error. system("perl -pi -e 's@words@words@g' myFile"); The error is: Unrecognized character \x8A; marked by <-- HERE after دت مد�<-- HERE near column 15 at -e line 1. Thanks in advance. ---------- Post updated at 06:30 AM... (0 Replies)
Discussion started by: Lham
0 Replies

7. UNIX for Dummies Questions & Answers

nohup (solved)

Hi, I have been running a program over ssh and it outputs data as a series of netCDF files to a directory. Being new to UNIX I have just found out (much to my delight) that I can run this in the background using nohup and log off while it runs. However it is now outputting to a file called... (0 Replies)
Discussion started by: davcra
0 Replies

8. Shell Programming and Scripting

How to use ssh execute other shell script on other host (shell script include nohup)?

i want use ssh on the host01 to execute autoexec.sh on the host02 like following : host01> ssh host02 autoexec.sh autoexec.sh include nohup command like follwing : nohup /home/jack/deletedata.sh & after i execute ssh host02 autoexec.sh one the host01. i can't found deletedata.sh... (1 Reply)
Discussion started by: orablue
1 Replies

9. Shell Programming and Scripting

Run Script With nohup Command On A Different Server

Hi, I want to run a particular script present in a different server. At the moment I am trying to run it like this: (sleep 3; echo $USERID; sleep 1; echo $PASSWORD ; sleep 1 ; sleep 1 ; echo "nohup perl myscript.pl $* &")| telnet "$server" But the problem is that once the script has... (6 Replies)
Discussion started by: King Nothing
6 Replies

10. Shell Programming and Scripting

Check if script run by a user directly or via other scripts

Hi, i have a script 'a.sh' that should be called only by certain scripts like b.sh, c.sh Inside a.sh, how can i determine 1) if this script was run directly from command prompt (or scheduler) 2) if called via other scripts? Is there an easy way to get parent process name (not just pid),... (2 Replies)
Discussion started by: ysrinu
2 Replies
Login or Register to Ask a Question
NOHUP(1)						    BSD General Commands Manual 						  NOHUP(1)

NAME
nohup -- invoke a command immune to hangups SYNOPSIS
nohup utility [arg ...] DESCRIPTION
The nohup command allows the specified utility to be protected from termination if the user should become logged out (for example, due to a modem line or TCP/IP connection being dropped). To do this, nohup sets the SIGHUP signal(3) (``terminal line hangup'') to be ignored, then executes utility along with any arguments. If the standard output is a terminal, the standard output is appended to the file nohup.out in the current directory. If standard error is a terminal, it is directed to the same place as the standard output. If the output file nohup.out cannot be created in the current directory, nohup attempts to create the file in the user's home directory. If the file nohup.out cannot be created, either in the current directory or the user's home directory, nohup will exit without invoking utility, with an exit value as described below. ENVIRONMENT
The following variable is used by nohup. HOME User's home directory. EXIT STATUS
The nohup utility exits with one of the following values: 126 The utility was found but could not be invoked. 127 The utility could not be found or an error occurred in nohup. Otherwise, the exit status of nohup will be that of utility. SEE ALSO
signal(3) STANDARDS
The nohup command is expected to be IEEE Std 1003.2 (``POSIX.2'') compatible. BSD
July 15, 2005 BSD