Solved

How to empty log file

Posted on 2004-09-07
4
573 Views
Last Modified: 2013-12-15
I'm quite new to linux, and was wondering what is the best way to empty / archive a log file.

The file in question is /var/log/messages

I tried:

mv /var/log/messages /var/log/messages.archive.07-09-2004
touch /var/log/messages    to create new empty log file

but now nothing is being written to the logfile! How can I fix this and how should I have done it?

Thanks.
0
Comment
Question by:mcwalters
  • 2
4 Comments
 
LVL 18

Accepted Solution

by:
liddler earned 50 total points
ID: 11996847
Usually messages log is rotated by a cronjob in roots cron, the command (in solairs, not in front of a linux box at the mo) is  /usr/lib/newsyslog, so it should be something similar.
Stopping and restarting syslogd should start it off again
0
 

Author Comment

by:mcwalters
ID: 11996879
Ok, tried:

service syslogd restart

but it doesn't recognise the service?
0
 

Author Comment

by:mcwalters
ID: 11996928
Got it working now - it was

service syslog restart

Thanks
0
 
LVL 5

Expert Comment

by:paranoidcookie
ID: 12006433
If you are worried about logsize try using a program like logrotate which cna be made to archive and compress log files automatically for you.
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ftp to port 21 4 53
winscp 000webhost.com 6 73
list of sudo access for date range 5 29
CLI command keep running after close 7 36
If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

856 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