Sponsored Content
Full Discussion: event number tracking
Top Forums Shell Programming and Scripting event number tracking Post 95212 by blowtorch on Monday 9th of January 2006 05:45:01 AM
Old 01-09-2006
Use a lock file. Like this:
Code:
while [ -f /logs/lockfile ]; do
   sleep 2
done
touch /logs/lockfile
curevent=`tail -1 /logs/eventnums | cut -f1 -d" "`
eventnum=$(($curevent + 1))
echo "$eventnum event info" >>/logs/central_events.log
echo $eventnum > /logs/eventnums
rm /logs/lockfile

Before we do anything, we can check for existence of the lock file and loop while it exists. Then when we get the all clear, we touch a lock file and then get to work. Once the job is done, we remove the lock file and let other cron jobs get on with it.

--This is not tested--
 

3 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Command Tracking

Hi, OS: Solaris9, SPARC Is there any way I can track the commands run by users from the shell prompt? Example: Somebody is deleting files from the system. Who it is is a mystery. That person obviously does not use bash prompt so there is no history. Is there anyway I can find out who... (5 Replies)
Discussion started by: mahatma
5 Replies

2. UNIX for Advanced & Expert Users

Tracking down the problem

Is there a way to track down what process is sending to a certain port? I have some thing pounding the network with requests to a multicast IP that doesn't exist. I have shut down all comms related processes and yet it is still there. Need a way to track the port or IP back to the process. Thanks... (3 Replies)
Discussion started by: mattmanuel
3 Replies

3. Programming

Methods for Random Number Tracking

what types of methods and algorithms are used to track random number generators? I'm working on computer security, and I want to know all the different ways to track random number generators so I know what to counter (8 Replies)
Discussion started by: azar.zorn
8 Replies
RLOCK(1)						      General Commands Manual							  RLOCK(1)

NAME
rlock - run program with a lockfile SYNOPSIS
rlock [options] lockfile program [args] rlock [options] lockfile -- program options [args] DESCRIPTION
rlock creates NFS safe lockfiles. it can optionally run a program while holding the lock, ensuring lockfile removal on program exit. if a program is specified to be run rlock will spawn a background thread to kept the lockfile 'fresh' by touching it at a regular interval. in this way a lease is maintained on the lockfile and other processes attempting to obtain the lock can determine that it is in use. see the '--refresh' option for how to control the touch interval. any other process trying to obtain a lock will automatically remove a stale lockfile; a stale lockfile is one that is older than a certain age. this age be controled via the '--max_age' option. ENVIRONMENT
LOCKFILE_DEBUG=1 causes internal actions of the library to be shown on STDERR. DIAGNOSTICS
rlock attempts to exit with the status of 'program' except where it cannot due to exceptional conditions. in addition the message 'RLOCK SUBCOMMAND FAILURE' will be printed on STDERR if 'program' exits with non-zero status. AUTHOR
lockfile was written by Ara T. Howard <ara.t.howard@noaa.gov>. This manual page was converted by Decklin Foster <decklin@red-bean.com> for the Debian project (but may be used by others). 2008-10-11 RLOCK(1)
All times are GMT -4. The time now is 04:21 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy