06-17-2005
Create a lock file
May be you could try this :
You could create a temporary zero byte lockfile and check for its existence every time before you run the script.If the file exists you can give a sleep command to wait for some time before checking again or exit.
You could remove this file just before your script ends its execution.
regards,
Srikanth
10 More Discussions You Might Find Interesting
1. UNIX for Advanced & Expert Users
Hi,
Is there any way in Unix to check for the system usage processwise ??
I mean I wud like to get a listing of running processes along with their CPU / memory utilisation so that I can spot dangerous the space / memory eaters ..
Thanks & regards,
SNS (2 Replies)
Discussion started by: Sabari Nath S
2 Replies
2. UNIX for Advanced & Expert Users
I want to find the pid ( by ps ) that has already run over 30 seconds , I know ps only show the minute/hour .
eg. the start time of the below process are 15:19 / 15:20 , but I don't know the exact time ( in term of "second" ) it start to run ( I only know the hour and minute ) , if I want to... (2 Replies)
Discussion started by: ust
2 Replies
3. Shell Programming and Scripting
how to kill the process that are idle over 30 minutes ? thx (2 Replies)
Discussion started by: ust
2 Replies
4. UNIX for Dummies Questions & Answers
Except the command "top" , is there other function / tool is used to check the process status in the system like
1. what process are running ?
2. how the CPU are allocating ?
3. how many swap is using ?
4. "
Thx. (1 Reply)
Discussion started by: ust
1 Replies
5. UNIX for Dummies Questions & Answers
Hi Everybody
I have small requirement that needs to be implemented in shell script.
Currently i have shell script which invokes a java process say "Process A" which runs in background.
If some one tries to invoke again the same shell script , then there should be some mechanism inside the... (23 Replies)
Discussion started by: appleforme1415
23 Replies
6. Solaris
How to find what are the cron jobs which are running at any instant on a Solaris server ??? The job can be scheduled from any id but still would like to list all the cron jobs which are running on the server ??? (2 Replies)
Discussion started by: helper
2 Replies
7. Shell Programming and Scripting
Hi..
I have this code which tells me that if a process is running or not. Actually someone on this forum help me to do it. :) But now If i want to check if the process is not running for more than 10 minutes. Does anyone know the code or syntax that checks if a process is not running for some... (1 Reply)
Discussion started by: kanexxx
1 Replies
8. Shell Programming and Scripting
Hi ,
I have a csh code below which check the process if it's running.
Can any expert advise me on the following:
1) what does this notationmean ">!" and how is it different from the append ">" notation ?
2) how does "setenv" work in this code ?
# Check whether there is a running... (3 Replies)
Discussion started by: Raynon
3 Replies
9. UNIX and Linux Applications
Hi
I would like to check if an instance of a script is already running.
I've seen many different examples, but I haven't the slightest idea as to how to do this.
Can you please help.
Thank you. (5 Replies)
Discussion started by: ladyAnne
5 Replies
10. UNIX for Dummies Questions & Answers
I have process1 running on one machine and generating some log file. Now another process which can be launched on any machine wants to know if process1 is running or not and also in case it is running it wants to stream the logs file generated by process1 on terminal from which process2 is... (2 Replies)
Discussion started by: saurabhnsit2001
2 Replies
LEARN ABOUT CENTOS
dotlockfile
DOTLOCKFILE(1) Cistron Utilities DOTLOCKFILE(1)
NAME
dotlockfile - Utility to manage lockfiles
SYNOPSIS
/usr/bin/dotlockfile [-p] [-c] [-m] [-l|-u|-t] [-r retries] [lockfile]
DESCRIPTION
Dotlockfile is a command line utility to safely create, test and remove lockfiles. Lockfiles are created in an NFS-safe way. Dotlockfile
can can also be used to lock and unlock mailboxes even if the mailspool directory is only writable by group mail.
The name dotlockfile comes from the way mailboxes are locked for updates on a lot of UNIX systems. A lockfile is created with the same
filename as the mailbox but with the string ".lock" appended.
The names dotlock and lockfile were already taken - hence the name dotlockfile :).
OPTIONS
-l Create a lockfile. This is the default.
-u Remove a lockfile.
-c Check for the existence of a valid lockfile.
-t Touch an existing lockfile (update the timestamp).
-p Write the process-id of the calling process into the lockfile. Also when testing for an existing lockfile, check the contents for a
process-id to find out if the lockfile is still valid.
-r retries
The number of times dotlockfile retries to acquire the lock if it failed the first time before giving up. The initial sleep after
failing to acquire the lock is 5 seconds. After each next try, a sleep of 5 seconds extra occurs up to a maximum sleep of 60 seconds
between tries. The default number of retries is 5.
-m Lock or unlock the current users mailbox. The path to the mailbox is the default system mailspool directory (usually /var/mail) with
the username as gotten from getpwuid() appended. If the environment variable $MAIL is set, that is used instead. Then the string
".lock" is appended to get the name of the actual lockfile.
lockfile
The lockfile to be created/removed, unless the -m option is in effect.
RETURN VALUE
Zero on success, and non-zero on failure. For the -c option, sucess means that a valid lockfile is already present. When locking (the
default, or the -l option) dotlockfile returns the same values as the library function lockfile_create(3). Unlocking a non-existant lock-
file is not an error.
NOTES
The lockfile is created exactly as named on the command line. The extension .lock is not automatically added.
This utility is a lot like the lockfile(1) utility included with procmail, and the mutt_dotlock(1) utility included with mutt. However the
command-line arguments differ, and so does the return status. It is believed that dotlockfile is the most flexible implementation, since it
automatically detects when it needs to use priviliges to lock a mailbox, and does it safely.
The above mentioned lockfile_create(3) manpage is present in the liblockfile-dev package.
BUGS
None known.
SEE ALSO
lockfile_create(3), maillock(3)
AUTHOR
Miquel van Smoorenburg, miquels@cistron.nl
15 May 2003 DOTLOCKFILE(1)