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
script to monitor process running on server and posting a mail if any process is dead pradeepmacha Shell Programming and Scripting 13 03-06-2009 07:33 AM
How to create a dummy process of a process already running? shambhu UNIX for Advanced & Expert Users 3 08-31-2007 10:22 AM
daemon running in AIX checking karthikosu UNIX for Dummies Questions & Answers 0 10-24-2006 12:49 PM
Shell running setup in Korn ? Browser_ice Shell Programming and Scripting 4 08-14-2006 08:22 PM
Korn Shell script not running Asty Shell Programming and Scripting 1 08-11-2006 01:17 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-30-2005
jph jph is offline
Registered User
  
 

Join Date: Apr 2005
Posts: 6
checking for a running process from korn cron

cron starts a job every 10 minutes via a korn shell - I need to determine if the previous process is still running before I allow the new process to start - HELP
I've tried ps -ef, etc but I have seen many situation where it says that the is running when it is not - any ideas on how to absolutely determine this
HELP
  #2 (permalink)  
Old 04-30-2005
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,119
Quote:
Originally Posted by jph
cron starts a job every 10 minutes via a korn shell - I need to determine if the previous process is still running before I allow the new process to start - HELP
I've tried ps -ef, etc but I have seen many situation where it says that the is running when it is not - any ideas on how to absolutely determine this
HELP
if on Solaris, look into 'man fuser'.
  #3 (permalink)  
Old 05-01-2005
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
Best way to implement this is to use a lock file. When the process starts up, have it look for a lock file (which should be a unique file name). If the file exists, the process can just exit. Otherwise, the process can touch the file and proceed to do its job. Just before exiting the process will remove the file.

Code:
#!/bin/sh
LOCKFILE=/tmp/lockfile # just suppose some name
if [ -f $LOCKFILE ]; then
exit
fi
touch $LOCKFILE  # create your lockfile so that any process starting up after 
                        # will find the file and exit
### start doing what you really want to do here
.
.
.
### end what ever you are doing here
rm -f $LOCKFILE
exit
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 04:06 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