0

I am working on setting tinyproxy on Centos 6.5 server in cloud. I have installed it successfully. However, because of cloud limitation in terms of size, we want to limit logfile (/var/log/tinyproxy.log) size. I need to configure log file so that it could keep information of last hour logs. For example, If now were 5.30 PM, so file must contain only data from 4.30 PM. I have read tinyproxy documentation and couldn't find logfile limit parameter. I'd be very thankful if somebody gave me a clue how to do that. Thanks.

forucell
  • 81
  • 2
  • 10

2 Answers2

0

I don't believe Tinyproxy has a feature for limiting log size, but it would be pretty simple to write a script for this separately.

An example script using Python, running automatically every hour using Linux crontab:

import os
import shutil
# Remove Old Logs
    os.remove(/[DESTINATION])
# Copy Logs to Storage
    copyfile(/var/log/tinyproxy.log, /[DESTINATION])
# Remove Primary Logs
    os.remove(/var/log/tinyproxy.log)

(This is just an example. You may have to clear tinyproxy.log instead of deleting it. You may even want to set it up so you copy the old logs one more time, so that you don't end up with only 1-2 minutes of logs when you need them.)

And add this to crontab using crontab -e (make sure you have the right permissions to edit the log file!). This will run your script every hour, on the hour:

01 * * * * python /[Python Path]/logLimit.py
Jason Brown
  • 15
  • 2
  • 9
0

I found crontab very useful for this task.

30 * * * * /usr/sbin/logrotate  /etc/logrotate.d/tinyproxy

It rotates my log file every hour.

Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
forucell
  • 81
  • 2
  • 10