# Log rotation

**URL:** https://community.unix.com/t/log-rotation/332662
**Category:** Solaris
**Created:** [August 5, 2013, 2:58am UTC](https://community.unix.com/t/log-rotation/332662 "2013-08-05T02:58:51Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![fretagi](https://community.unix.com/letter_avatar/fretagi/32/5_5575768a8748004e209b776fc1b2916d.png) [@fretagi](https://community.unix.com/u/fretagi)
#### Post date: [August 5, 2013, 2:58am UTC](https://community.unix.com/t/log-rotation/332662/1 "2013-08-05T02:58:51Z")

</div>

Hi All!

I seem to have a problem with log rotation, unless I am doing something wrong, I have type the following command for testing purposes to see if the

```nohighlight
 -s 

```

option works but he did not:

```nohighlight
 logadm -w /var/adm/messages -C 8 -c -s 512k -t '/var/adm/messages.$n' -z 1

```

the file is now at this size:

```nohighlight
-rw-r--r-- 1 root root 146452271 Aug 5 08:56 messages

```

and did not create copies of the

```nohighlight
messages

```

file as stated on the

```nohighlight
logadm -w

```

command.

Please can I have some help

---

<div class="post-metadata">

### Author: ![hergp](https://community.unix.com/letter_avatar/hergp/32/5_5575768a8748004e209b776fc1b2916d.png) [@hergp](https://community.unix.com/u/hergp)
#### Post date: [August 5, 2013, 3:17am UTC](https://community.unix.com/t/log-rotation/332662/2 "2013-08-05T03:17:02Z")

</div>

Check `/etc/logadm.conf` to see, if the entry was written correctly and check root's crontab, if the `/usr/sbin/logadm` cronjob ist still there.

---

<div class="post-metadata">

### Author: ![fretagi](https://community.unix.com/letter_avatar/fretagi/32/5_5575768a8748004e209b776fc1b2916d.png) [@fretagi](https://community.unix.com/u/fretagi)
#### Post date: [August 5, 2013, 3:35am UTC](https://community.unix.com/t/log-rotation/332662/3 "2013-08-05T03:35:26Z")

</div>

It has, I have used the

```nohighlight
logadm -V

```

command to check

---

<div class="post-metadata">

### Author: ![hergp](https://community.unix.com/letter_avatar/hergp/32/5_5575768a8748004e209b776fc1b2916d.png) [@hergp](https://community.unix.com/u/hergp)
#### Post date: [August 5, 2013, 4:53am UTC](https://community.unix.com/t/log-rotation/332662/4 "2013-08-05T04:53:58Z")

</div>

Did the logadm-cronjob run after you made your modification? This is not clear in your post. The statement you posted only updates the config file but does not perform any actions.

You can also try to run logadm manually with the verbose switch on:

```nohighlight
logadm -v

```

---

<div class="post-metadata">

### Author: ![fretagi](https://community.unix.com/letter_avatar/fretagi/32/5_5575768a8748004e209b776fc1b2916d.png) [@fretagi](https://community.unix.com/u/fretagi)
#### Post date: [August 5, 2013, 6:13am UTC](https://community.unix.com/t/log-rotation/332662/5 "2013-08-05T06:13:20Z")

</div>

Hi!

After running

```nohighlight
logadm -v

```

it created another file

```nohighlight
messages.0

```

and compressed

```nohighlight
messages.1

```

, but now current messages file is bigger that 512K set

```nohighlight
-s 512k

```

.  
Should�nt that file after reaching 512k being automatically renamed to

```nohighlight
message.0

```

and created a new

```nohighlight
message

```

file?

---

<div class="post-metadata">

### Author: ![hergp](https://community.unix.com/letter_avatar/hergp/32/5_5575768a8748004e209b776fc1b2916d.png) [@hergp](https://community.unix.com/u/hergp)
#### Post date: [August 6, 2013, 2:56pm UTC](https://community.unix.com/t/log-rotation/332662/6 "2013-08-06T14:56:07Z")

</div>

I am not sure, if it is necessary to send a SIGHUP to syslog when using the copy-truncate-option ( `-c` ). You might give it a try. Add `-a 'kill -HUP `cat /var/run/syslog.pid`'` to the commandline.

---

<div class="post-metadata">

### Author: ![MadeInGermany](https://community.unix.com/letter_avatar/madeingermany/32/5_5575768a8748004e209b776fc1b2916d.png) [@MadeInGermany](https://community.unix.com/u/MadeInGermany)
#### Post date: [August 6, 2013, 3:28pm UTC](https://community.unix.com/t/log-rotation/332662/7 "2013-08-06T15:28:04Z")

</div>

`-a 'kill -HUP `cat /var/run/syslog.pid`'` is necessary, because syslogd needs to close and re-open its file handle.  
`-c ` does not break anything - but slows things down.

---

<div class="post-metadata">

### Author: ![hergp](https://community.unix.com/letter_avatar/hergp/32/5_5575768a8748004e209b776fc1b2916d.png) [@hergp](https://community.unix.com/u/hergp)
#### Post date: [August 7, 2013, 3:13am UTC](https://community.unix.com/t/log-rotation/332662/8 "2013-08-07T03:13:26Z")

</div>

> [@madeingermany](#):
>
> ... because syslogd needs to close and re-open its file handle.

Not necessarily, if the logfile is opened with O\_APPEND. The OP uses `-c` to truncate the logfile. So the inode stays the same and if the file is opened with O\_APPEND, then it should be written starting with byte 1.

But if syslog does not use O\_APPEND, then the filepointer stays at an offset of some 500k and continues to write from here, resulting in a sparse file. In this case the SIGHUP is needed.
