Limit the size of the logfile

Is it possible to limit the size of the log file?
I have the -v tag set so I can monitor activity, I would still like to see this level of detail but don’t want the log files to get enormous over time.

Is it possible to put a max size on the file?

1 Like

Heh i know what you mean, i made simple cron script that will compress & truncate log file once its over 100MB

you can change the compress part with delete eg change
tar -cpzf $task-$BACKUPTIMESTAMP.tar.gz $task | tee -a "$LOGFILE"
rm $task | tee -a "$LOGFILE"

Why not just use logrotate? It’s built in to basically all Linux distros (assuming you’re using one of these).

create a filer under /etc/logrotate.d/ named rclone or whatever.

/var/log/rclone.log {
rotate 4

That will keep 4 days worth, although you could change this to a week or month if you wanted. Old logs are compressed. (assumes you are saving to /var/log/rclone.log which is where I output mine to.

You can then use ‘zcat’ on the compressed logs rather than cat to display/search them.