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
stop execution of script with in the script dsdev_123 AIX 3 03-20-2008 11:57 AM
Script that doesn't stop biot UNIX for Dummies Questions & Answers 3 11-30-2007 01:19 AM
Script does not stop when doing a read rooseter Shell Programming and Scripting 7 11-05-2007 01:46 PM
stop Prstat using shell script filthymonk Shell Programming and Scripting 19 05-23-2007 05:24 AM
Start/Stop Script jjv1 UNIX for Dummies Questions & Answers 2 12-16-2003 04:28 PM

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 11-06-2007
Raynon Raynon is offline
Registered User
  
 

Join Date: Sep 2006
Location: Sg
Posts: 350
Script to run non-stop

Hi All,

I am on a Solaris OS and i have come up with a csh script named " mycshscript " which will grab data from a datalog file & format the grabbed data & upload formated version to web server. I would want to have this script to run non-stop so that the latest can be captured since data is always appending to the datalog file. Below is a skeleton of my script using a while loop to loop non-stop.

My question is that
1) Does closing my command console stop the running of my script?
2) If i want to stop my script from running, how am i able to do it in a clean manner?


Code:
#!/bin/csh

set num = 1

while ($num == 1)

......
.......

end
  #2 (permalink)  
Old 11-06-2007
porter porter is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2007
Posts: 2,965
Quote:
Originally Posted by Raynon View Post
Does closing my command console stop the running of my script?
Normally.

The traditional solution is

Code:
nohup myprogram &
and run it from a shell without job control.

This will

(a) run the program in the background
(b) ignore any SIGHUP generated by the terminal "hanging up".
  #3 (permalink)  
Old 11-06-2007
Raynon Raynon is offline
Registered User
  
 

Join Date: Sep 2006
Location: Sg
Posts: 350
Hi Porter,

1) How do i stop the process if i need to?
2) how do i need to create a while loop for this ?
3) If there's an echo command, will it be printed out ?
4) Do i need to add in the " nohup myprogram & >/dev/null 2>&1 " just like cronjob to remove all the echoing and printing command ?
  #4 (permalink)  
Old 11-06-2007
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,953
Quote:
and run it from a shell without job control.
Not necessarily.

I could do the same with ' ksh / zsh ' - which has a good job control.

Would that create any difference ?
  #5 (permalink)  
Old 11-06-2007
porter porter is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2007
Posts: 2,965
Quote:
Originally Posted by matrixmadhan View Post
Would that create any difference ?
Run it from a shell that when you try to exit the shell doesn't refuse because it complains you still have jobs running.

Quote:
Originally Posted by Raynon
3) What if there's no redirection operators ? What will happen ?
man nohup, typically end up with a file called "nohup.out".

Quote:
Originally Posted by Raynon
4) Can i use this ?
nohup myprogram & >/dev/null 2>&1
Sure, as always, give it a go, see what it does, try and break it.
  #6 (permalink)  
Old 11-06-2007
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,953
Quote:
Run it from a shell that when you try to exit the shell doesn't refuse because it complains you still have jobs running.
I agree, that would not hinder the running process.

Its more like a warning and that could be very much ignored.
  #7 (permalink)  
Old 12-23-2007
Raynon Raynon is offline
Registered User
  
 

Join Date: Sep 2006
Location: Sg
Posts: 350
Quote:
Originally Posted by porter View Post
Run it from a shell that when you try to exit the shell doesn't refuse because it complains you still have jobs running.



man nohup, typically end up with a file called "nohup.out".



Sure, as always, give it a go, see what it does, try and break it.
Hi Porter,

If there's some mismatch in the input file which causes the script to output an error -> " Unrecognized command: ,$ p ". Will this be appended to the file "nohup.out" as well ?
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 09:26 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