Clearing the Routers Logfiles
Clearing the Router s Logfiles
Problem
You want to delete the contents of the router's logfiles.
Solution
Use the clear log command to delete the contents of a logging file:
aviva@router1> clear log messages
Discussion
Logging files fill up with messages very quickly, and if you are trying to debug a recent problem, you may be overwhelmed with the number of older messages. This command removes the messages from a file:
aviva@router1> clear log messages aviva@router1> show log mes? Possible completions: Name of log file messages Size: 59, Last changed: Mar 09 15:24:43 messages.0.gz Size: 8886, Last changed: Mar 03 04:00:00 messages.1.gz Size: 7820, Last changed: Feb 22 12:00:00 messages.10.gz Size: 7834, Last changed: Feb 10 04:00:00 messages.2.gz Size: 9189, Last changed: Feb 18 04:00:00 messages.3.gz Size: 7115, Last changed: Feb 17 21:00:01 messages.4.gz Size: 7191, Last changed: Feb 17 09:00:00 messages.5.gz Size: 7579, Last changed: Feb 16 22:00:00 messages.6.gz Size: 7241, Last changed: Feb 16 10:00:01 messages.7.gz Size: 9059, Last changed: Feb 15 23:00:01 messages.8.gz Size: 17682, Last changed: Feb 15 11:00:01 messages.9.gz Size: 14807, Last changed: Feb 15 04:00:01 aviva@router1> show log messages Mar 9 15:24:43 router1 clear-log[29140]: logfile cleared
To free up disk space, you can also delete logfiles that you are no longer using (for example, if files are left over from a previous debugging operation) or files that you no longer need. Here, we logged RIP protocols operations a while ago to debug a problem and now want to delete those logfiles:
aviva@router1> file list detail /var/log/rip* -rw-r----- 1 root 1689 Feb 28 10:05 /var/log/rip-update-log -rw-r----- 1 root 7610 Feb 28 10:05 /var/log/rip-update-log.0.gz -rw-r----- 1 root 7286 Feb 28 09:39 /var/log/rip-update-log.1.gz -rw-r----- 1 root 7427 Feb 28 09:15 /var/log/rip-update-log.2.gz -rw-r----- 1 root 7334 Feb 28 08:49 /var/log/rip-update-log.3.gz -rw-r----- 1 root 7316 Feb 28 08:25 /var/log/rip-update-log.4.gz -rw-r----- 1 root 7382 Feb 28 08:01 /var/log/rip-update-log.5.gz -rw-r----- 1 root 7380 Feb 28 07:37 /var/log/rip-update-log.6.gz -rw-r----- 1 root 7243 Feb 28 07:12 /var/log/rip-update-log.7.gz -rw-r----- 1 root 7346 Feb 28 06:48 /var/log/rip-update-log.8.gz total 10 aviva@router1> file delete /var/log/rip* aviva@router1> file list /var/log/rip* /var/log/rip*: No such file or directory