Sponsored Content
Full Discussion: event number tracking
Top Forums Shell Programming and Scripting event number tracking Post 95216 by matrixmadhan on Monday 9th of January 2006 06:17:46 AM
Old 01-09-2006
Quote:
Originally Posted by blowtorch
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--

torch,

if we are using a separate lock file to maintain integrity there is always a problem that it could be corrupted or accidentally deleted during processing.

here is a very similiary approach to yours, to make use of the existing file and work around with the permission bits

Code:
#check whether the file with sequence number is denied of read-access
while [ ! -r <file_with_seqno> ]
do
sleep 1
done

curevent=`tail -1 /logs/eventnums | cut -f1 -d" "`

#revert the read permission to maintain integrity
chmod -r <file_with_seqno>

eventnum=$(($curevent + 1))
echo "$eventnum event info" >>/logs/central_events.log
echo $eventnum > /logs/eventnums

#reset the access permission as before
chmod +r <file_with_seqno>

 

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
update(n)						       Tcl Built-In Commands							 update(n)

__________________________________________________________________________________________________________________________________________________

NAME
update - Process pending events and idle callbacks SYNOPSIS
update ?idletasks? _________________________________________________________________ DESCRIPTION
This command is used to bring the application ``up to date'' by entering the event loop repeatedly until all pending events (including idle callbacks) have been processed. If the idletasks keyword is specified as an argument to the command, then no new events or errors are processed; only idle callbacks are invoked. This causes operations that are normally deferred, such as display updates and window layout calculations, to be performed imme- diately. The update idletasks command is useful in scripts where changes have been made to the application's state and you want those changes to appear on the display immediately, rather than waiting for the script to complete. Most display updates are performed as idle callbacks, so update idletasks will cause them to run. However, there are some kinds of updates that only happen in response to events, such as those triggered by window size changes; these updates will not occur in update idletasks. The update command with no options is useful in scripts where you are performing a long-running computation but you still want the applica- tion to respond to events such as user interactions; if you occasionally call update then user input will be processed during the next call to update. SEE ALSO
after(n), bgerror(n) KEYWORDS
event, flush, handler, idle, update Tcl 7.5 update(n)
All times are GMT -4. The time now is 04:32 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy