![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
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 |
|
|||||
|
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
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|