Web Hosting Talk







View Full Version : Are these commands safe?


ClusterMania
07-17-2002, 08:42 AM
My harddrive files up with logs fast

cp /dev/null access_logs
cp /dev/null error_logs

ho247
07-17-2002, 08:45 AM
Yes. those commands should be fine, if you're looking to reset the error and access logs to zero. Have you setup log rotation on your logs? That will allow your logs to grow and then deleted after some time.

Alan

chirpy
07-17-2002, 09:24 AM
There's more to it than just the copy. You must also restart apache immediately after having done the copies otherwise you will run into all sorts of problems with lost log file information when you do eventually restart and the space won't actually be freed up on the file system.

As suggested, look into logrotate (man logrotate) and make sure it is running daily and configured correctly.

ClusterMania
07-17-2002, 09:42 AM
What are some must know commands for freebsd? What are the top 20 commands that you use the most to solve problems?

chirpy
07-17-2002, 10:00 AM
You're probably best either buying a beginners guide to *BSD/*NIX, or looking for one on the web, that explains from the beginning how to approach the subject from being a user to a systems administrator. It takes a rich combination of learning, experimenting and experience and is probably best done through the guidance of a publication, at least initially.

If you must, I'd make sure that you're familiar with and understand (in no particular order) the following generic utilities:
cd
pwd
pico
vi
tar
pwd
ps
top
netstat
df
cp
mv
rm
rpm (for various Linux platforms)
less
last
grep
find
cat
tail

(I counted them too, there're 20 ); )

Mdot
07-17-2002, 11:14 AM
Could you explain how is it going to work? :eek:
Open httpd.conf and comment/delete the line that says where to write logs and you're finished.
How can you copy device? /dev/null is device, not a file, explain please. :confused:

Studio64
07-18-2002, 07:44 PM
/dev/null. AKA the bit bucket, that to which all data must go, or the great terminator in the sky. /dev/null is a special Unix device which goes nowhere. Nada. Nothing. Kaput. This is the end of the line

From everything2.com

ToastyX
07-18-2002, 08:43 PM
Wow, I've never seen a file cleared out that way. I usually just do ">filename" to redirect the output of no command, which is nothing, to the file.

mwatkins
07-19-2002, 05:30 AM
But do you really want to clear out your access_logs? Either you or your clients may have numerous future needs of them.

Why not just gzip them instead, rotate them, etc?

clocker1996
07-19-2002, 06:01 AM
i always thought it was................

rm -f access_log
ln -s /dev/null $PWD/access_log

or path/to/access_log

??
oh well

I believe you can also just do rm -f logfile
and thats it
dont restart
just leave it

should be fine also

chirpy
07-19-2002, 11:15 AM
I believe you can also just do rm -f logfile
and thats it
dont restart
just leave it

No . :angry: You must restart apache as it will continue to write to the files even if you think you have deleted them as they are open to the process and the space you think you have saved is not returned to the file system. A simple look at the Apache documentation shows you this :rolleyes: :
http://httpd.apache.org/docs/logs.html#rotation

Mdot
07-19-2002, 11:19 AM
I'm looking at you guys and asking myself: isn't it easier to turn off the logs? :eek:

:stickout

Warren
07-19-2002, 12:42 PM
No, no it isn't.

ClusterMania
08-17-2002, 01:27 PM
rm -f access_log
rm -f error_log
apachectl graceful

cp /dev/null access_logs
cp /dev/null error_logs
apachectl graceful

Hmm, I have tried both these and my harddrives are still full.

bitserve
08-17-2002, 01:49 PM
You might want to shut down apache, truncate the logs, then start apache back up.

2host.com
08-17-2002, 01:59 PM
Originally posted by ClusterMania
rm -f access_log
rm -f error_log
apachectl graceful

cp /dev/null access_logs
cp /dev/null error_logs
apachectl graceful

Hmm, I have tried both these and my harddrives are still full.

Log rotation to process (if you want), compress or delete the logs, is best. cp is pointless, just type "echo -n > /path/to/log_file" and it will overwrite it with no content. You can also delete it and "touch" a new one. Once you restart Apache it will start logging again, so you can create a symbolic link to point the log file to /dev/null and it will not grow again (if you don't want logs).

You can also set the directive in Apache to write the logs to /dev/null as well. Finally, the graceful command might not work, depending on your Apache build, so you might need ot execute a "start" or "startssl". Be sure to either restart, or stop and then start (or startssl). It's really that simple.