Operating System - OpenVMS
1826703 Members
2919 Online
109696 Solutions
New Discussion

Re: Rotate accounting log?

 
Fredrik.eriksson
Valued Contributor

Rotate accounting log?

Hi,

As the topic says, is there anyway to rotate the accounting log (SYS$MANAGER:ACCOUNTNG.DAT) while having the system running?

For some reason the file hasn't been renewed when the machine been rebooted and still contain entries from 2004. To make this abit more manageable I would like to start a new accounting file if that is possible.

Best regards
Fredrik Eriksson
2 REPLIES 2
Fredrik.eriksson
Valued Contributor

Re: Rotate accounting log?

Found it myself, just googled way wrong :)
$ set accounting /new_file

Best regards
Fredrik Eriksson
John Gillings
Honored Contributor

Re: Rotate accounting log?

Fredrik,
Small caveat...

$ set accounting /new_file

is not synchronous. Therefore, you cannot be guaranteed the old file is closed or the new file opened at completion of the command. If you're scripting a rollover, and wish to do something with the old version, you need to synchronize. Something like (untested):

$ old=F$SEARCH(F$PARSE("ACCOUNTNG","SYS$MANAGER:.DAT;"))
$ oldfid=F$FILE_ATTRIBUTES(old)
$ SET ACCOUNTING/NEW_FILE
$ SyncLoop: IF F$FILE_ATTRIBUTES(F$PARSE("ACCOUNTNG","SYS$MANAGER:.DAT;"),"FID").EQS.oldfid
$ THEN
$ WAIT 0:0:1 ! 1 second delay
$ GOTO SyncLoop
$ ENDIF
$!
$! At this point the rollover has completed
$! and the old file is free to be RENAMEd
$ RENAME 'old' whatever...

(you may want to add a sanity check in case the rollover fails).
A crucible of informative mistakes