Tag Info

Hot answers tagged

38

I suppose you are searching for: tail -F /var/log/kern.log The -F option tells tail to track changes to the file by filename, instead of using the. inode number which changes during rotation. It will also keep trying to open the file if it's not present.


24

Most likely, the log file is less than a day old and/or has been rotated within the last day and logrotate remembers the history. If you add -f it'll force a rotation if you really want to (although not 100% sure how that interacts with -d). You can look at the history, location depends on your distribution, but might be /var/lib/logrotate/status. That ...


20

Try it with -f or --force: zcat -f -- * man zcat for details. Also: so that I can pipe the output to grep for example You have zgrep for that: zgrep -- PATTERN *


17

zless It seems a pity about zcat, as libz has an API that supports reading from both compressed and uncompressed files transparently. But the manpage does say that zcat is equivalent to gunzip -c.


14

The reason that apache needs a reload is that once it's opened a file, it gets a filehandle to it, and it will keep writing to that filehandle. When you move the file, it doesn't see that, it just keeps writing to the same handle. When you do a reload, it'll open the file again and get a new handle. To avoid the reload, instead of moving the file, you can ...


10

Depending on your OS. Some (all?) Linux distributions have a directory /etc/cron.hourly where you can put cron jobs to be executed every hour. Others have a directory /etc/cron.d/. There you can put cron-jobs that are to be executed as any special user with the usual cron-settings of a crontab entry (and you have to specify the username). If you use either ...


7

That is probably a mistake, it is found only in one example on that tutorial. All other examples have copytruncate without the create option. Also logrotate man page says that is will be actually ignored: copytruncate Truncate the original log file to zero size in place after creating a copy, instead of moving the old log file and optionally ...


5

I won't discuss logging with regard to ubuntu specifically much, since the topic is standardized for linux in general (and I believe most or all of what I have to say is also true in general for any flavor *nix, but don't take my word for that). I also won't say much about "how to read logs" beyond answering this question: Is the assumption even correct ...


5

Unix signal delivery is asynchronous. When the kill system call returns, the signal has been delivered to the process, but the process may not have reacted to it yet. You were lucky with the scheduler under 11.04. If the killed process has a handler for the signal, it can spend an arbitrarily long time before dying, or choose not to die as a result of the ...


5

It's called logrotate because typically it is used to "rotate" logs to new files periodically -- that is, it doesn't delete or refresh them (at least from my interpretation of those words). One definition of "rotate" provided by the Random House Dictionary is: to cause to go through a cycle of changes or follow in a fixed routine of succession: to ...


4

The first time you run logrotate with a new log configuration it doesn't know when the last log rotation occurred. So it just writes a status line in logrotate.status to the effect that it was run today. When it subsequently runs the following day, it sees that the log is a day old and rotates it as expected. If you don't want to wait, edit ...


4

The usual solution for this problem is to use rotate the logfiles so that the current logfile only contains current entries, rather than removing outdated entries from the file. This is all handled by the logrotate program. The following configuration should do approximately what you want. It will keep the last 6 months of log entries from ...


4

logrotate uses crontab to work. It's scheduled work, not a daemon, so no need to reload its configuration. When the crontab executes logrotate, it will use your new config file automatically. If you need to test your config you can also execute logrotate on your own with the command: logrotate /you/config/file Or as mentioned in comments, identify the ...


3

I recommend you to use http://cronolog.org/ This is how I use it: CustomLog "|/usr/local/sbin/cronolog -S /var/log/httpd/t3.CCC.eu-access_log -P /var/log/httpd/t3.CCC.eu-access_log.prev /var/log/httpd/t3.CCC.eu-%Y.log" combined


3

There is logrotate which cleans /var/log regularly by using cron jobs. It is normally installed automatically (at least in Debian and its derivatives like Ubuntu).


3

You can run multiple instances of logrotate. They need to work on different sets of files and use different state-files. You should use gzip (standard compression) instead of bzip. AFAIK you can pass some extra options to gzip - so you can tell it to use faster compression.


3

Please tell us more about your requirements - it's hard to guess what limits your server: disk i/o? You might want to spread out those logfiles over disks/filesystems cpu - is it compressing those logs as they are rotated? You might want to use a filesystem with internal compression, and even hardware acceleration. directory cache? see the answer by Chris ...


3

logrotate can do it with olddir if your log file name is the same every time it runs and you can add dates. If your log file name changes i.e. YYYYMMDD then logrotate won't do it for you. # sample logrotate conf file copytruncate compress dateformat %Y%m%d. dateext extension log olddir ./logarchive /logs/sys.log { rotate 7 daily } Copies and ...


3

You could write a little bash script to do this. Just tail the file to a certain byte count using tail -c and overwrite the file. from man tail: -c, --bytes=N output the last N bytes; alternatively, use +N to output bytes starting with the Nth of each file If the first character of N (the number of bytes or lines) is a ...


3

Most of the logrotate setups I've seen on various distros runs out of the /etc/cron.daily. There's a shell script there aptly named logroate. Example $ ls -l /etc/cron.daily/logrotate -rwxr-xr-x 1 root root 180 May 18 2011 /etc/cron.daily/logrotate Manual run If you want to make it run manually simply run the script as root. $ sudo ...


3

Rotating a log file is not sufficient, you have to tell the process that's writing to it to stop as well. You typically can do this by sending a signal to the process, such as a HUP. Example /var/log/snmpd.log { notifempty missingok postrotate /bin/kill -HUP `cat /var/run/snmpd.pid 2> /dev/null` 2> /dev/null || true endscript ...


3

X's logging behavior is: If there is a /var/log/Xorg.DISPLAY.log, rename it to /var/log/Xorg.DISPLAY.log.old, overwriting any file that might be there. Open /var/log/Xorg.DISPLAY.log, and begin logging to it. Unfortunately, this isn't configurable, except in the sense all open-source software is: you could change the source code and recompile. It's in ...


3

The logrotate option that does what you describe is copytruncate. Simply add this option to your existing logrotate config. Here is the excerpt from the logrotate.conf manual: copytruncate Truncate the original log file in place after creating a copy, instead of moving the old log file and optionally creating a new one, ...


2

Usually maillog written by syslogd, not by sendmail itself, so you should send SIGHUP to syslogd


2

logrotate itself does not do this. I'd recommend writing a supplementary script and invoking it from logrotate using the postrotate option in the configuration.


2

Here's a quickie script which will do what you need: #!/bin/bash LOGDIR=/var/log/somedir OLDLOGS=/var/log/keep-old-logs-here PATH=/bin:$PATH TODAY=$(date +'%Y%m%d') [ -d $OLDLOGS ] || mkdir -p $OLDLOGS cd $LOGDIR for LOG in $(ls | egrep '^[[:digit:]]{8}$'); do [ $LOG -lt $TODAY ] && gzip $LOG && mv $LOG.gz done Make the script ...


2

How about here for starters


2

I think tmpwatch or tmpreaper might do what you need. Both are already in the respective distros. # CentOS yum install tmpwatch # Debian/Ubuntu aptitidue install tmpreaper


2

There's quite a mess in your permissions in /var/log/munin and in your config file. You have different user/group pair for your files and diffrent group/pair in your configuration. You have 2 choices in order to solve your problem Use default root:root permissions Specify in ALL your munin rules the same user/group pair First, you can reset ...


2

From man logrotate: copytruncate Truncate the original log file to zero size in place after creat‐ ing a copy, instead of moving the old log file and optionally creating a new one. It can be used when some program cannot be told to close its logfile and thus might continue writing ...



Only top voted, non community-wiki answers of a minimum length are eligible