Sponsored Content
Top Forums UNIX for Advanced & Expert Users How to prevent job1 from running while job2 is running.. Post 302088724 by blowtorch on Thursday 14th of September 2006 05:01:30 AM
Old 09-14-2006
Use lockfiles. Before any job starts, make sure it checks for a lockfile. If the file exists, exit. If it does not, have it create the lockfile and proceed to do its actual job. At the end, remove the lockfile.

If you have two jobs and one lockfile, you'll get only one job running at any given time.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

My script is not running

I have wriiten the following scripts in UNIX. The file name is bk.ksh rman target=/ << EOF RUN { SHUTDOWN IMMEDIATE STARTUP MOUNT ALLOCATE CHANNEL ch1 device TYPE DISK FORMAT '/u01/oradata/ora/%U'; BACKUP DATABASE PLUS ARCHIVELOG; SQL'ALTER DATABASE OPEN' ;} EXIT; EOF when i try... (8 Replies)
Discussion started by: manna
8 Replies

2. Solaris

Running from Shell Vs running from RC script

Hi, i have a script which need to do behave differently when run as a startup process from init.d/ rc2.d script and when run manually from shell. How do i distinguish whether my script is run by init process or by shell?? Will the command /proc/$$/psinfo | grep "myscript" work well???... (2 Replies)
Discussion started by: vickylife
2 Replies

3. Programming

defunct vs running

hello everybody! Is there any way to identify if a process is defunct or if it is still running? (in C). for example: by using a signal such as SIGCHLD? thanx in advance (1 Reply)
Discussion started by: nicos
1 Replies

4. UNIX for Dummies Questions & Answers

too many inetd running

hi, is it ok for more than one inetd daemon running at a time? if not okay, possible to kill the rest and make only one daemon running? i understand that inetd is a process that enables tcp connections from external sources...kindly advise more on inetd...thanks alot..Happy New Year!:) (2 Replies)
Discussion started by: cromohawk
2 Replies

5. Shell Programming and Scripting

Running Total Running Wild

Hi. A shell scripting newbie here. I am trying to write a script that will create a running total of Sales, and increment a counter for each Sales entry, but when I executed the program it never stopped. counter=0 Sales=0 echo "enter sales price" read sales while do let counter=counter+1... (6 Replies)
Discussion started by: Ccccc
6 Replies

6. Shell Programming and Scripting

prevent running of duplicate scripts

i have a script tool.sh,but i want to include a script within it that checks if tool.sh is already running,if already running then the new one called should exit,but if not then the new one should proceed and run. i want to prevent the duplicate running of the script. (5 Replies)
Discussion started by: tomjones
5 Replies

7. AIX

AIX - "prevent script from running twice" issue

I know about standard "ps ..|grep .. | grep -v grep" solution, but... this is different issue I have encountered in several companies I worked for. And I see this only for AIX - not HP, not Solaris, not Linux. Korn shell script is scheduled in the background (via cron /via Tivoli Scheduler or... (6 Replies)
Discussion started by: ooops
6 Replies

8. Shell Programming and Scripting

Cron job running for some days and is not running for some days

Hi.. i have written a shell script and made this script to run on every day night 11: 55 pm using a cron job. This cron job running for some days and is not running for some day. but i need this script to run every day night. Please help me. Here is the cron tab entries, 55 23 * * *... (1 Reply)
Discussion started by: vidhyaS
1 Replies

9. Shell Programming and Scripting

Why script is running sometimes and not running sometimes?

Hi, I have a script which does couple of database connection and run some SELECT queries to get some output in the file. I am surprised to see :eek: that when i run my script some times it gives the desired out put and sometimes it shows some error :confused: . Suppose if i execute it say... (3 Replies)
Discussion started by: Sharma331
3 Replies

10. UNIX for Beginners Questions & Answers

Script not running

hi i have a alarm file mentioned as below alarm_log.15122017 i want to fetch failure detail but script is not working . kindly let me now where is the mistake #!/bin/bash cd /scripts/ DATE=`date "+ %d%m%Y"` ls -lrt | grep -i "alarm_log.$DATE" cat alarm_log.$DATE |grep -B 1... (6 Replies)
Discussion started by: scriptor
6 Replies
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)
All times are GMT -4. The time now is 04:49 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy