-6
I host my website at GoDaddy. I have a 9GB log file that I want to delete. I've logged in via SSH as root.
How do I delete the log file?
Filename Size Last modified
birja-vdv.az_access_log 9 GB 2:20 AM
-6
I host my website at GoDaddy. I have a 9GB log file that I want to delete. I've logged in via SSH as root.
How do I delete the log file?
Filename Size Last modified
birja-vdv.az_access_log 9 GB 2:20 AM
5
Try this command
locate birja-vdv.az_access_log
The answer will be something like
/var/log/birja-vdv.az_access_log
You could then
rm /var/log/birja-vdv.az_access_log
However, if your web-server is holding the log-file open, the actual file does not get deleted until the web-server closes the log file. You should get the web-server to close and re-open it's log files. With thye Apache webserver you may be able to restart it using a command such as
apachectl graceful
As Silviu suggests most people prefer to set up something like logrotate
to automatically rename old log files and delete the oldest.
See StackOverflow Best way to rotate Apache log files
and Apache Rotatelogs
I'd check GoDaddy's help pages before proceeding. They are a very big hosting company and will very likely have some easy means for you to manage log files (perhaps through a web control-panel)
It asks rm: remove regular file `/var/log/httpd/birja-vdv.az_access_log'? What should i type? – Neo – 2012-05-15T10:10:48.043
1@Neo y
for yes, or n
for no. To be honest, you should consider reading some tutorials about basic Linux commands and Bash usage before you go about removing stuff from a web server. – slhck – 2012-05-15T10:48:02.133
I strongly approve the comment from slhck. If you're meant to administer your hosted web server, then before doing anything you should learn the basics. You don't try to fix a car engine before knowing it's basic principles/concepts. – Huygens – 2012-05-15T11:24:32.947
Thanks guys, i sent this info to my web programmer, i love you all and this website, thanks! – Neo – 2012-05-15T19:51:37.117
2
Your log files are most likely at /var/log
(cd /var/log
)
Once there, do a file listing (ls -asl
) and look for the log files. Old log files are mostly archived and they can be seen as "logname.#.tar.gz
" i think (or bz2, not sure). Depending if you need them or not, you can delete them either by hand (single file names, or the logs of an entire application as in "rm apache*.tar.gz
"
If cleaning up /var/log doesn't help you (delete enough files), look up what uses most of your hard drive with "du -h
", but be careful what you delete.
4 -rw-r--r-- 1 root root 126 Jan 29 18:29 * 4 dr-xr-x--- 2 root root 4096 Mar 28 19:10 . 4 dr-xr-xr-x 20 root root 4096 May 14 04:10 .. 8 -rw------- 1 root root 4195 May 15 02:32 .bash_history 4 -rw-r--r-- 1 root root 18 Mar 30 2009 .bash_logout 4 -rw-r--r-- 1 root root 176 Mar 30 2009 .bash_profile 4 -rw-r--r-- 1 root root 176 Sep 22 2004 .bashrc 4 -rw-r--r-- 1 root root 100 Sep 22 2004 .cshrc 4 -rw------- 1 root root 40 Feb 1 05:43 .mysql_history 4 -rw------- 1 root root 3997 Mar 28 19:54 .support_history – Neo – 2012-05-15T09:49:01.793
4 -rw-r--r-- 1 root root 129 Dec 3 2004 .tcshrc 8 -rw------- 1 root root 4136 Mar 28 18:08 .viminfo 216 -rw-r--r-- 1 root root 214761 Mar 28 19:10 mailerror – Neo – 2012-05-15T09:49:26.460
3@Neo: When adding information, it is sometimes better to edit your question rather than add a comment. Your listing can be formatted in the question so that it is easier to read, you can't format comments. The command Andreas meant you to enter was cd /var/log; ls -asl
. – RedGrittyBrick – 2012-05-15T09:54:40.913
In case the file was given to you by godaddy and you can't find it, use find / -name birja-vdv.az_access_log
, if you have the full path follow what Daniel Andersson said, read up about rm and delete it using the full path. – Andreas – 2012-05-15T09:55:13.227
i found it. It looks like /var/log/httpd/birja-vdv.az_access_log – Neo – 2012-05-15T10:00:08.260
1
My guess is that you want to delete your apache log files. Even if you will delete them now, it's good practice to use:
logrotate
You can check more here.
Judging from the rest of his comments, trying to grasp logrotate
would probably blow up his head. :-) – DevSolar – 2012-05-15T11:15:18.990
4Do you have the path of the log file? Then just
rm pathtologfile
. -1, lack of research effort. Also unclear is why you have a 9GB log file, which might be relevant to the question. And what kind of log file it is. – Daniel Andersson – 2012-05-15T09:37:48.987It's a access log.i have info in SCP – Neo – 2012-05-15T09:39:25.473
rm birja-vdv.az_access_log
– Daniel Andersson – 2012-05-15T09:43:23.143it says no such directory – Neo – 2012-05-15T09:44:11.537
2You have to be in the directory or give the full path. Learn to use the manual, such as
man rm
. In all frankness, if you don't know how therm
command works or how you can find out, you should make sure that you know this before starting to delete files on anyone's advise. – Daniel Andersson – 2012-05-15T09:47:19.973