In message <4ceff099.6050...@umn.edu>, Tim Peiffer writes: >I have a backup application that writes logs to file names that are >dated.. e.g. logfile.MMDDYY , and I am looking for the best way of >detecting the existence of the file, and then open the file from the >beginning under SEC. [...] > >The -input=logfile* glob is ok, but is only useful on start/restart, >with the new logs being effectively invisible until the next restart. I >have tried dropping symbolic links in a directory that I have write >access to linking the fixed target with the monitored file name >logfile.MMDDYY.
If the directory is on the same filesystem as the log file you can use a hard link to the log file instead of a symbolic link. >When the file is created by the application, SEC >handles the new monitored file name as a log file shuffle. What I am >thinking is that at midnight, I remove the existing link, and then >re-link to the monitored file name. I wrote the below example, and it >works as expected, but I am interested how SEC will handle the hours in >between the time of symbolic link creation, and the time of the >monitored file creation. IIRC it just sits there as though the file doesn't exist yet. However what you can also do is change the link only if the new file is there, so you never have a dangling link. Rather than: > type=Calendar > time=* * * * * > desc=create new logfile sym link > action=spawn ( \ > cd /Users/peiffer/sec-2.5.3/glob ; \ > rm logfile ; \ > ln -s logfile.`date +%m%d%y` logfile \ > ) use (note this uses a hard link not symbolic but read on): #****v* calendar/relink_current # SYNOPSIS # relink_current - created hard link to newest log file in directory # DESCRIPTION # Every minute find the most recently written log file and obtain it's # inode number. Obtain the inode number of the file current (which # must exist). If they have the same inode number, exit status 0. If # they don't force current to be linked to the most recently written # log file. #****** type = calendar time = * * * * * desc = relink current file action = shellcmd (/bin/sh -c 'lastfile=`ls -tr ../*.log| tail -n 1`; [ `stat --printf "%i" current` -eq `stat --printf "%i" $lastfile` ] || ln -f $lastfile current') and use sec -input=current. This command lists the last log file (ls -tr ../*.log | tail -n 1), then it uses the stat command to print the inode of the last logfile and compares it to the file current in the current directory (where I have write access). If the inodes are different it links the file current to the new log file. This works fine provided 2 new log files aren't created within 1 minute. (If they are only the last log file gets monitored, the others are ignored.) I think stat also support the -L flag to dereference a symbolic link, so this should work with minor changes if you want to use ln -s rather than ln (which you will have to if you are on different filesystem). The advantage of this method is that the file that SEC is following never changes unless there is a new log file to follow. (If you don't have stat on your system, the gnu coreutils software provides one, or you can use a perl one liner.) -- -- rouilj John Rouillard =========================================================================== My employers don't acknowledge my existence much less my opinions. ------------------------------------------------------------------------------ Increase Visibility of Your 3D Game App & Earn a Chance To Win $500! Tap into the largest installed PC base & get more eyes on your game by optimizing for Intel(R) Graphics Technology. Get started today with the Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs. http://p.sf.net/sfu/intelisp-dev2dev _______________________________________________ Simple-evcorr-users mailing list Simple-evcorr-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/simple-evcorr-users