Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
I am trying to rotate a custom log for an active process. I can successfully rotate the log from the command line using:
logrotate -f /etc/logrotate.d/customlog (where customlog is the config file)
config file customlog contains:
create 0664 user user}
The rotation works but the running process does not write to the newly created logfile. How do I rotate the log and recreate the original log so that the live running application will now write to the recreated original log file?
well this is the applications problem, not logrotate. logrotate will generally hup the process writing to it to encourage it to close all files and reopen them, but if you application doesn't perform those actions on a hup then that's not an option. You can use the postrotate options to run a small amount of arbitrary code upon completion of the rotation, e.g. stopping and starting the program, or a final solution is to NOT replace the file - use the copytruncate option to clone the file and delete the contents, leaving the original file in place, but now empty. Again this has its own issues if the app writing to it tries to access the file after the end, but that's a fair few ways around your issue, so one should hopefully be good enough.
Chris, the copytruncate option worked perfectly! I would like to put this in cron as well now. I could just run the line that works in cron, but can I run the entire logrotate.d to rotate all system logs (i.e. logrotate -f /etc/logrotate.d/*)? Or is it more complex than that? If necessary I would be happy to open anothre thread for this additional request.