I'm really struggling to understand how logrotate
works when running a command within a shell file of my own, and how it doesn't.
The command in question is:
rclone -L -vv --log-file "/home/mike/tmp/qqq.log" sync "/media/mike/W10 D drive/My Documents/" remote:MyDocuments_M17A_from_Linux
What I would like:
I would like this qqq.log file to be checked quite often, say every 10 min., to see whether it has exceeded a given size, say 1 MB. And if it has, to rotate the file. rclone
with the -vv
option produces copious output, deliberately (i.e. to try to understand to get logrotate working for this use case).
There's a moderately helpful tutorial here, but it still leaves me in the dark:
How are you meant to configure rotation of logs from your own non-system processes? Are you meant to stick lines at the bottom of
/etc/logrotate.conf
? This is what I have done (under "#system-specific logs may be configured here"):/home/mike/tmp/qqq.log { notifempty size 1M daily create 0664 root root rotate 3 }
later: I now realise you can also put individual files in
/etc/logrotate.d
- no great complexity there.Is it the case that by default
logrotate
only runs once a day, by virtue of the file/etc/cron.daily/logrotate
?Does that mean that if I want much more frequent checking I should perhaps set up a
cron
job to do this, running (in this example) every 10 minutes?Are you meant to run
logrotate <config file>
as root? I ask this question because I have tried both as root and as user. User didn't seem to work.
A link to a beginner's guide to this sort of setup, which can't be that uncommon, would be helpful. I have searched but most of what I've found doesn't give you a step-by-step guide.
logrotate
in the first place, when (with suitable application of things like/dev/stderr
if necessary) one can just do the task directly in the script. unix.stackexchange.com/a/340631/5132 unix.stackexchange.com/a/326166/5132logrotate
so my disks don't get jammed up with monstrous log files. There's also the "right tools for the job" argument, which I'm not qualified to answer... although I assumelogrotate
is probably meant to do what it says on the tin.rclone
you set an option,--log-file
... the process just carries on regardless, spewing out log messages. Do those other tools you reference run ascron
jobs? (As I presumelogrotate
does...)?