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!
Notices
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.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have a log file , that keep the record of system activities , as below , now the log is appending so that it becomes very large .
"
05/01/08 Normal userA
05/01/08 Normal userB
05/02/08 Alnormal userC
"
"
10/01/08 Normal userA
10/02/08 Normal userA
"
Now I would like to keep the log current , so if the date is over 60 days , then remove this row , like above , the first three row should be removed as 05/01/08 and 05/02/08 is over 60 days ( today is 10/08/08 ) , can advise how to do it ? thx
To expand, you can't easily remove the top/front of an open file being written to.
The usual solution is to use the logrotate utility as mentioned.
See /var/log
For a static/non-open file you can extract the top or bottom of a file using the head and tail cmds.
To expand, you can't easily remove the top/front of an open file being written to.
The usual solution is to use the logrotate utility as mentioned.
See /var/log
For a static/non-open file you can extract the top or bottom of a file using the head and tail cmds.
except logrotate , can give me the hits to write a script to do that ? thx
but I have some problem when run it in my distro .
I have read the man page of logrotate , I think the below part is function works for my case , but I am not too understand how it fit to my requirement , could advise do I need to write the script to make it ? thx
so it gets called daily. The logrotate files (like yours) are stored in
/etc/logrotate.d
you just need to look for the equiv on your distro. You'll need to do it as root.
Looks like you need to fix that kill cmd though... its unreadable here.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.