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)							   User Commands							  NOHUP(1)

NAME
nohup - run a command immune to hangups, with output to a non-tty SYNOPSIS
nohup COMMAND [ARG]... nohup OPTION DESCRIPTION
Run COMMAND, ignoring hangup signals. --help display this help and exit --version output version information and exit If standard input is a terminal, redirect it from /dev/null. If standard output is a terminal, append output to `nohup.out' if possible, `$HOME/nohup.out' otherwise. If standard error is a terminal, redirect it to standard output. To save output to FILE, use `nohup COMMAND > FILE'. NOTE: your shell may have its own version of nohup, which usually supersedes the version described here. Please refer to your shell's doc- umentation for details about the options it supports. AUTHOR
Written by Jim Meyering. REPORTING BUGS
Report nohup bugs to bug-coreutils@gnu.org GNU coreutils home page: <http://www.gnu.org/software/coreutils/> General help using GNU software: <http://www.gnu.org/gethelp/> Report nohup translation bugs to <http://translationproject.org/team/> COPYRIGHT
Copyright (C) 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. SEE ALSO
The full documentation for nohup is maintained as a Texinfo manual. If the info and nohup programs are properly installed at your site, the command info coreutils 'nohup invocation' should give you access to the complete manual. GNU coreutils 8.5 February 2011 NOHUP(1)