Three options:
Don't run this from crontab but instead use a while loop with a sleep 60 at the end and background it. No chance of it doubleing up on itself then.
Or
Have your script look for 'itself' in the process table before doing anything, if it's finds itself there already, exit. You've already written the code to do this in the script you provided above, just have to duplicate it and change PROCESS_NAME to your script name.
how can I lock my keyboard while I'm away from the computer without using lock command. What other commands gives me the option to lock keyboard device?
thanks (7 Replies)
Hello all,
If anyone has time, I have a few questions:
How do I do the following in Linux. We are using Red Hat and Oracle Enterprise Linux, which is based on Red Hat too.
1. How to lock the account after a few (like 3) invalid password attempts?
2. How do you lock a screen after 30... (1 Reply)
I am trying to create a script that will take a very large, tab delimited file and then lock accounts.
File headers look like this
id desc server pass sudo lock
test Test user server01 67 no no
"Test user" is under the desc column
Basically if pass column is greater... (5 Replies)
Hi,
I have a ksh shell script that accesses databases to drop and create tables and the script also creates text files.
This shell script is accessed thru a java application that i would like to turn multi-user, but the only way that i can do that is if I can figure out a way to lock the shell... (2 Replies)
Hi all,
I have to test some user priviliges. The goal is to be sure that an unauthorized user can't restart some modules (ssh, mysql etc...).
I'm trying to automate it with a shell script but in same cases I got the syslog broadcast message.
Is there any way to simply get a return code... (3 Replies)
Hi All,
newbie here, is it possible to lock my second script? because my 1st script is still running.
Ex.
1st run : 1st script.sh --> running.....
2nd run : 1st script.sh --> lock because the script is still running..
i don't have any idea how to do it.
Please advise,
Thanks,... (1 Reply)
Hi All,
Seeking for your assistance on how to lock the script if it's running? meaning anybody can't run my script while it's running.
Please advise,
Thanks, (8 Replies)
Hi All,
My requirement is i have a script A.sh .When a person A runs the script A.sh it should get locked and person B should not run the script.
i followed the below code
f_script_lock()
{
process=$1
user=`ps -ef | grep -i "$process" | grep -i 'ksh' | awk '{print $1;}'`
if ; then
... (1 Reply)
Hi,
I am new to perl and have a script to which i want to ensure that no matter how many ever times i execute the script it should execute only once per day. Cronjob is not a safe method as I want to built in capability inside the script. (1 Reply)
Discussion started by: ctrld
1 Replies
LEARN ABOUT CENTOS
shlock
SHLOCK(1) General Commands Manual SHLOCK(1)NAME
shlock - create lock files for use in shell scripts
SYNOPSIS
shlock -p pid -f name [ -b ] [ -u ] [ -c ]
DESCRIPTION
Shlock tries to create a lock file named name and write the process ID pid into it. If the file already exists, shlock will read the
process ID from the file and test to see if the process is currently running. If the process exists, then the file will not be created.
Shlock exits with a zero status if it was able to create the lock file, or non-zero if the file refers to currently-active process.
OPTIONS -b Process IDs are normally read and written in ASCII. If the ``-b'' flag is used, then they will be written as a binary int. For
compatibility with other systems, the ``-u'' flag is accepted as a synonym for ``-b'' since binary locks are used by many UUCP pack-
ages.
-c If the ``-c'' flag is used, then shlock will not create a lock file, but will instead use the file to see if the lock is held by
another program. If the lock is valid, the program will exit with a non-zero status; if the lock is not valid (i.e., invoking
shlock without the flag would have succeeded), then the program will exit with a zero status.
EXAMPLES
The following example shows how shlock would be used within a shell script:
LOCK=/var/run/innd/LOCK.send
trap 'rm -f ${LOCK} ; exit 1' 1 2 3 15
if shlock -p $$ -f ${LOCK} ; then
# Do appropriate work
else
echo Locked by `cat ${LOCK}`
fi
HISTORY
Written by Rich $alz <rsalz@uunet.uu.net> after a description of HDB UUCP locking given by Peter Honeyman. This is revision 1.9, dated
1996/10/29.
SHLOCK(1)