The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to rename Xterm terminal in VNC session bache_gowda UNIX for Dummies Questions & Answers 0 04-16-2007 06:44 AM
sqlplus session being able to see unix variables session within a script 435 Gavea Shell Programming and Scripting 2 07-03-2006 10:11 AM
mac 10.4>terminal>linux remote server>ssh login accepted>session closed-why? xprankard UNIX for Dummies Questions & Answers 0 01-21-2006 10:09 AM
terminal 8/ new Xwindows session moxxx68 UNIX for Advanced & Expert Users 1 05-26-2005 10:43 AM
Running Terminal and/or X-Windows in Mac OS X liquidcross UNIX for Dummies Questions & Answers 2 07-24-2002 10:59 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-01-2007
jjinno jjinno is offline
Registered User
  
 

Join Date: Jul 2007
Location: Cloud 9
Posts: 72
Running a script without a terminal session

I'm trying to figure out how I can run a script "myScript.sh" in such a way that if my remote network connection gets disconnected, the script doesn't stop functioning.

Right now I log in, run "./myScript.sh" and watch my output get pumped to a log file for about 10 hours. Only problem is that if I (or my ISP) closes my network connection ever, I have to start the whole thing all over again.

I have heard something about creating a .pid file and somehow running the script in a different session, but how do I go about doing that?
  #2 (permalink)  
Old 10-01-2007
reborg's Avatar
reborg reborg is offline Forum Staff  
Administrator
  
 

Join Date: Mar 2005
Location: Ireland
Posts: 4,211
have a look at 'man nohup'
  #3 (permalink)  
Old 10-02-2007
jjinno jjinno is offline
Registered User
  
 

Join Date: Jul 2007
Location: Cloud 9
Posts: 72
WOW thats awesome. I have been looking for that for ages!

You are my hero!
  #4 (permalink)  
Old 10-03-2007
dmwaff dmwaff is offline
Registered User
  
 

Join Date: Aug 2001
Location: Texas
Posts: 17
All you really need to know

1. nohup command = Don't send a Hang Up Signal to the process if shell exits
2. If you don't redirect output it attempts to create a nohup.out log file in your present working directory which maybe fine, but I find UGLY.
3. You have to background (&) the process.

4. Best Practice, example of execution

cd /path/to/bin/directory
nohup `pwd`/script.sh 1>/path/to/logdir/logfile.out 2>&1 &
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:02 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0