So the past few posts detailed how to parse Portfolio’s logs to find troublesome files as well as how to restart Portfolio’s services.
Well when Portfolio is struggling to catalog files, it can generate massive amounts of temp files & folders, which if not maintained can fill the Portfolio hosts hard drive.
Not a great situation, so I’ve written the below to help automate the maintenance.
There are three main locations to clear.
By default on OS X Portfolio stores its logs files in /Applications/Extensis/Portfolio Server/logs/.
The full list of logs created is shown below:
admin_server_access.log admin_server.log boot.log elasticsearch_index_indexing_slowlog.log elasticsearch_index_indexing_slowlog.log elasticsearch.log extensis.admin.log jboss.out media-delegate_access.log media-delegate.log native-agent.log native-processor.log server.log usage.log
With the following rolled over daily:
admin_server_access.log admin_server.log elasticsearch.log media-delegate_access.log media-delegate.log server.log usage.log
Portfolio has settings for limiting log retention, but as per the below they only apply to the admin.log & server.log.
These two files themselves are pretty small, but some of the others I have seen grow to 1.8GB.
By default on OS X, Portfolio generates it’s work files within /Applications/Extensis/Portfolio Server/data/work/.
Whilst the contents of these folders is generally small, they can number in their thousands as per the below (the folders shown were all generated in less than 24 hours):
Whilst Portfolio is supposed to use the above work folder to generate previews when cataloging items.
However the image-magics process creates temp files starting magick-* within /private/var/tmp, as shown below:
Again, the above were all generated within 24 hours. So that’s around 450GB eaten up.
At this time we were not restarting Portfolio’s services on a schedule, so the above were generated by processes over the following day & were not being removed.
The below script targets the above directories (unless you change the path for their variable), & in the case of the work & tmp folders: deletes any files or folders not modified today.
The idea is to run the script at an appropriate time of day, (like 3am), where if the files & folders have not been modified that day it means that they are orphaned & the script can then delete them.
For the log files, this is set to delete any logs last modified 5 days ago. This can be changed by changing the number within the below:
The script needs the mailServer, mailFrom & mailTo variables to have a value. Then the script will email a summary of what’s it’s deleted whenever run.
The script writes a lot file to /private/var/tmp/ that is overwritten every time the script is run.
Example output from the script:
2016-01-15 03:00:03,304 INFO ----- 3 Log files deleted 2016-01-13 03:00:06,100 INFO ----- 9155 Work folders deleted 2016-01-15 03:00:07,325 INFO ----- 21 Magick files deleted