-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Stuart Bird wrote:
> 
> When I run this script it seems to work, with one major problem. After
> running the script the messages file will no longer populate with data
> until reboot the system. I was hoping to run this as a cron job, but
> can?t if I have to reboot each time.
> 
> Have I got something wrong, or do I need to add something to stop this
> happening.
> 

For efficiency most logs file programs don't keep opening and closing
their log files for each extra log line, instead keeping the log open
continuously.

When you open a file is the only time that the filename gets used - it
is translated to the underlying storage location data which is used
subsequently.

As a result of both of the above, if you rename, delete, etc a file
which is still open, any new writes will still go to the old file (which
may be inaccessible if you deleted it).

As this a common request, most log file making daemons will accept a
signal (often HUP) to force a close & reopen of the log file. Otherwise
a restart of the daemon would be needed.

Syslogd does the HUP thing, so a killall -HUP syslogd should be what you
need.

I would also suggest adjusting the order of your script, so that the log
is moved, reopened (HUP) then compressed, as a log line sent to the
still open log file during or after compression will probably break things.

Have you looked at "logrotate" which does all of the above, and is
fairly standard?

- --
Stuart Clark
mailto:[EMAIL PROTECTED]
http://www.Jahingo.com/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFXN7b+aecWiCY5VYRAhdCAKCFzwdVKxX6uuYGK7GXTB7lpl+yhwCfZlc9
DbUQJ++yUlHrABZ1J4piIkc=
=rlMt
-----END PGP SIGNATURE-----

_______________________________________________
Peterboro mailing list
[email protected]
https://mailman.lug.org.uk/mailman/listinfo/peterboro

Reply via email to