# Running script on log rotation?



## nielsk (Sep 6, 2021)

For some of my log files I would like to run a script when the logs are rotated with newsyslog. Those are logs that include IPs and I’d like to anonymize those when the rotation is happening. This I would have IPs for the day but on rotation I would like to remove the last two octets. 
is that possible? If so, how?


----------



## Eric A. Borisch (Sep 6, 2021)

Look at newsyslog.conf(5)’s R option. Note you may need to have whatever script you put together pass along a signal to the respective log file’s owner to alert it to rotation.

As for cleaning up the rotated log, I would look to sed(1).


----------

