[...]
So what I've did is to have it this way:
and it worked... don't know why it behaved that way.
This should work fine if you're sure that your script will always be executed with bash
(and - really less likely to happen - that the name of the script will never appear in the process list for some other reason).
You may implement a lock/flag file like this:
1. In the above demo I'm using some constructs that are not available in the old (the traditional) Bourne shell (the parameter expansion).
2. In one place I'm using a non standard (not POSIX) syntax, but that construct is available in most modern shells.
On HP-UX, in application, if the process id has been get with the getpid() and sotred in database, then other monitor process want to check it if the process is existed, are there any system function can do it? I do not want to use the shell script, because it should use popen function to excuted... (5 Replies)
Hi Experts,
Is there any command by which i can chk that the cron process is running fine? Say i have scheduled the cron to run at 10 o clock every monday,Do i need to wait for the time it runs and then chk using ps -ef?
Please shed some light.
Thanks
Ashok. (2 Replies)
Hi
I have a scenario where i need to check multiple instances of a running shell script (abc.sh) .
How can I find from inside a running shell script whether any other instance of the same script is running or not? If any other instance of same shell script is running I need to exit from... (4 Replies)
Hi all,
I have the following code:
if ; then echo 'folder not exist'; else echo 'folder exist'; fi
The "testing" folder is not exist in /home/batch , but thhe result is 'folder exist'. It seems that the code cannot detect that the folder "testing" not exist.
ANybody know the... (1 Reply)
Hi,
I want to create a script who will check if the java process is running & if it finds the process is still there it continues to execute & when the process completes it exit from the script.
I have written a code to check & notify the process existence but i am not getting how to write... (4 Replies)
How can i check block process in Linux?
If found any what action is required?
How to check the pid of process?
How to kill the block process?
How to find out bottleneck process? (3 Replies)
Hi,
I need to know who can I create an script in order to check server mirror in AIX. I got this script
!/usr/bin/ksh
#
# Check if a VG is mirrored.
#
# lsattr -El <lvname> -a strictness -a copies
# If copies=2 and scrictness=y, then VG is mirrored
#
# LVs are retrieved via 'lsvg -l... (5 Replies)
Good morning, I have a python 2.3 script that runs stand alone as intended when tested, then it was put into a ksh script. when running the ksh script it runs as intended. The problem is that my script does not run when the ksh script is called by another user who runs a batch process (as of right... (1 Reply)
Hello Everyone,
I have a process that should be always running. Unfortunately, this process is getting down almost every 10 minutes. I want to make a script that verify the state of this process: If the process is up, the script shouldn't do nothing and if it's down he should run it.
Can... (3 Replies)
Hi All,
I am writing script for Env refresh for Oracle DB. I am using Datapump for that. If i start expdp or impdp, how can i know that export or import has completed. I have query for that. How will i integrate with script?. Or any command i can run from Linux side. Please share you... (1 Reply)
Discussion started by: pvmanikandan
1 Replies
LEARN ABOUT OPENSOLARIS
halockrun
halockrun(1M) System Administration Commands halockrun(1M)NAME
halockrun - run a child program while holding a file lock
SYNOPSIS
/usr/cluster/bin/halockrun [-nsv] [-e exitcode] lockfilename
prog [args]
DESCRIPTION
The halockrun utility provides a convenient means to claim a file lock on a file and run a program while holding that lock. As this utility
supports script locking, this utility is useful when programming in scripting languages such as the Bourne shell. See sh(1).
halockrun opens the file lockfilename and claims an exclusive mode file lock on the entire file. See fcntl(2)fcntl(2)). Then it runs the
program prog with arguments args as a child process and waits for the child process to exit. When the child exits, halockrun releases the
lock, and exits with the same exit code with which the child exited.
The overall effect is that the child prog is run as a critical section, and that this critical section is well-formed, in that no matter
how the child terminates, the lock is released.
If the file lockfilename cannot be opened or created, then halockrun prints an error message on stderr and exits with exit code 99.
You can run this command in the global zone or in a non-global zone. The command affects only the global or non-global zone in which you
issue the command.
OPTIONS
The following options are supported:
-e exitcode Normally, errors detected by halockrun exit with exit code 99. The -e option provides a means to change this
special exit code to a different value.
-n The lock should be requested in non-blocking mode: if the lock cannot be granted immediately, halockrun exits
immediately, with exit code 1, without running prog. This behavior is not affected by the -e option.
Without the -n option, the lock is requested in blocking mode, thus, the halockrun utility blocks waiting for
the lock to become available.
-s Claim the file lock in shared mode, rather than in exclusive mode.
-v Verbose output, on stderr.
EXIT STATUS
Errors detected by halockrun itself, such that the child process was never started, cause halockrun to exit with exit code 99. (This exit
code value can be changed to a different value using the -e option. See OPTIONS.
Otherwise, halockrun exits with the same exit code with which the child exited.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWscu |
+-----------------------------+-----------------------------+
|Interface Stability |Evolving |
+-----------------------------+-----------------------------+
SEE ALSO fcntl(2), attributes(5)Sun Cluster 3.2 10 Apr 2006 halockrun(1M)