Freebsd – Logrotate maually on FreeBSD 8

freebsdlogrotatelogs

I am able to rotate any log file manually via logroatate like this:

logrotate -f /etc/logrotate.d/my-hourly-file

I want to know how to perform the same action on FreeBSD 8?

My investigation shows that newsyslog can be used for this purpose. If so how can I download and install newsyslog?

Update: I think newsyslog has been installed and modifying the /etc/newsyslog.conf file will be enough for automatic installation. But how can I trigger it manually?

Update2: when I search all newsyslog words starting from /, I only found /etc/rc.d/newsyslog script. Inside the script I realized that newsyslog command is defined under /usr/sbin/newsyslog. But there is not newsyslog file under /usr/sbin/newsyslog.

I am stuck that how I can install newsyslog package into FreBSD 8

Best Answer

It seems like you're new to FreeBSD, and coming from a Linux background.

Let's clear a few things up --

First, newsyslog isn't a package -- it's a program that comes with the base FreeBSD operating system. You shouldn't have to install it, and it should always be there.
If /usr/sbin/newsyslog is missing from your system someone has deleted it (for reasons I can't fathom) -- Find the previous sysadmin and find out what they did, and why.
(You may optionally want to beat them with a stick for removing core OS utilities.)

If you need to get newsyslog back in a hurry you can rebuild it from source, or copy it from another 8.x system. If you're in less of a hurry you can rebuild and install world which will also correct a number of other problems you may have on an inherited system (You should first make sure that this won't muck up any other measures you have in place for patching servers, and observe all the red boxes warning you to make backups).


Once you have newsyslog back you can force it to rotate log files one of two ways:

  • newsyslog -F will force ALL log files in newsyslog.conf to be rotated immediately.
  • newsyslog -R <files> will force the specified files to be rotated immediately.

Further information can be found in the newsyslog man page

Related Question