Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

managing /var/apache/access_log  and error_log

Posted on 2006-07-03
9
Medium Priority
?
323 Views
Last Modified: 2013-12-27
My /var/apache/access_log and error_log are getting to big. I want to just keep the last 500 lines of each. Can I use the tail -500 comand and copy to another file and remove the original and rename the file witrh the last 500 lines to the original and can I do this while the system is running?
0
Comment
Question by:mslibrarycommission
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 10

Accepted Solution

by:
Nukfror earned 500 total points
ID: 17031582
0
 
LVL 38

Assisted Solution

by:yuzh
yuzh earned 500 total points
ID: 17034362
Or use cron to run a script to rotate the logs:

see my script in http:Q_21891238.html#16939051
0
 
LVL 48

Assisted Solution

by:Tintin
Tintin earned 500 total points
ID: 17039624
yuzh.

In your rotation script, I  would change

cp -p access_log access_log.${TODAY}
cp -p error_log error_log.${TODAY}
cat /dev/null > access_log
cat /dev/null > error_log

to

mv access_log access_log.${TODAY}
mv error_log error_log.${TODAY}

As mv is an atomic process and will be much quicker than copying the logs.  Additionally, if your logs are big and your freespace is low, you may run into space issues.

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 38

Expert Comment

by:yuzh
ID: 17039693
Tintin,
     thanks for the suggestion, after "mv", you need to "re-create" the log files
and set the correct file permissions (use "touch + chmod").
0
 
LVL 1

Assisted Solution

by:Johntuck
Johntuck earned 500 total points
ID: 17194514
Easiest way to recreate those log files after a mv is: apachectl graceful

It'll recreate everything for you with the default permissions- much less room for script error :)

If you traffic is high enough, this could be done every 10-15 min.
0
 
LVL 38

Expert Comment

by:yuzh
ID: 17557557
We have given the working answers, split points?
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question