log – TecAdmin https://tecadmin.net How to guide for System Administrator's and Developers Tue, 21 Jun 2022 07:54:09 +0000 en-US hourly 1 https://wordpress.org/?v=6.1.1 How to Clear Log Files of A Docker Container https://tecadmin.net/truncate-docker-container-logfile/ https://tecadmin.net/truncate-docker-container-logfile/#comments Mon, 09 Mar 2020 17:16:10 +0000 https://tecadmin.net/?p=20944 This tutorial will help you clear the log file on a Docker container. If your system is getting out of disk space and you found that the docker container’s log files are consuming high disk space. you can find the log file location and clear them with the help of this tutorial. While clearing log [...]

The post How to Clear Log Files of A Docker Container appeared first on TecAdmin.

]]>
This tutorial will help you clear the log file on a Docker container. If your system is getting out of disk space and you found that the docker container’s log files are consuming high disk space. you can find the log file location and clear them with the help of this tutorial. While clearing log files of a docker container, you don’t need to stop it.

Clear Docker Container Log File

Below are the 3 different options to clear log files of Docker containers. Choose any one of the below options to truncate the docker container log files.

Some of the below options require a container id or name, which can be found with the docker ps -a command.

  • Option 1: In this option, first we will find the log file path and then truncate it. Use inspect option to find the log file name and location of a docker container.
    docker container inspect  --format='{{.LogPath}}' <container_name_or_id>
    

    As a result, you will get a log file path. Now truncate the log file with the following command.

    truncate -s 0 /path/to/logfile 
    

    Here -s is used to set the size of a file. You provided 0 as input, which means completely truncating the log file.

  • Option 2: You can combine both commands in a single command. Use the following command to truncate the log file of the specified Docker container.
    truncate -s 0 $(docker inspect --format='{{.LogPath}}' <container_name_or_id>) 
    
  • Option 3: Truncate the log files of all docker containers in your system.
    truncate -s 0 /var/lib/docker/containers/*/*-json.log 
    

You can quickly truncate the docker log files using one of the above options.

Wrap Up

In this blog post, you have learned to truncate (clear) log files of a Docker container.

The post How to Clear Log Files of A Docker Container appeared first on TecAdmin.

]]>
https://tecadmin.net/truncate-docker-container-logfile/feed/ 4
How to Remove/PURGE BINARY LOGS in MySQL & MariaDB https://tecadmin.net/purge-binary-logs-in-mysql/ https://tecadmin.net/purge-binary-logs-in-mysql/#comments Wed, 22 Jul 2015 17:51:14 +0000 https://tecadmin.net/?p=7985 Binary log files contains data about modification’s make by MySQL server. You can see there are multiple binary files will be available on your MySQL server and there will be one .index file which contains names of all binary files to keep track of them. Step 1. List Binary Files First list binary log files [...]

The post How to Remove/PURGE BINARY LOGS in MySQL & MariaDB appeared first on TecAdmin.

]]>
Binary log files contains data about modification’s make by MySQL server. You can see there are multiple binary files will be available on your MySQL server and there will be one .index file which contains names of all binary files to keep track of them.

Step 1. List Binary Files

First list binary log files in your system and find out how old binary log files you want to delete. These files generally located under /var/lib/mysql directory.

# ls -a /var/lib/mysql 

...
-rw-rw---- 1 mysql mysql   3800220 Jul 21 15:15 mysql-bin.000733
-rw-rw---- 1 mysql mysql   1076727 Jul 21 15:40 mysql-bin.000734
-rw-rw---- 1 mysql mysql    263024 Jul 21 15:42 mysql-bin.000735
-rw-rw---- 1 mysql mysql  13895153 Jul 22 00:36 mysql-bin.000736
-rw-rw---- 1 mysql mysql   2717571 Jul 22 01:02 mysql-bin.000737
-rw-rw---- 1 mysql mysql   4080285 Jul 22 03:49 mysql-bin.000738
...

Step 2. PURGE Binary Logs

Now use any one of following commands to delete older binary log files as per your system requirements.

  • Delete binary log file mysql-bin.000735 or older files.
    mysql> PURGE BINARY LOGS TO 'mysql-bin.000735';
    
  • Delete all binary log files created till date “2015-07-21 23:59:59”.
    mysql> PURGE BINARY LOGS BEFORE '2015-07-21 23:59:59';
    

Now list binary log files again, You will find that all older logs has been removed from mysql directory.

The post How to Remove/PURGE BINARY LOGS in MySQL & MariaDB appeared first on TecAdmin.

]]>
https://tecadmin.net/purge-binary-logs-in-mysql/feed/ 2
How to Setup LogAnalyzer with Rsyslog and MySQL https://tecadmin.net/setup-loganalyzer-with-rsyslog-and-mysql/ https://tecadmin.net/setup-loganalyzer-with-rsyslog-and-mysql/#comments Tue, 31 Dec 2013 03:43:04 +0000 https://tecadmin.net/?p=3744 This article is second part of the article Setup Rsyslog with MySQL and LogAnalyzer on CentOS/RHEL systems. In the first part we have integrated Rsyslog with MySQL database server, and all the logs are now saving in database. For recalling below is few configuration details which we used in part-1 to setup it. Rsyslog MySQL [...]

The post How to Setup LogAnalyzer with Rsyslog and MySQL appeared first on TecAdmin.

]]>
This article is second part of the article Setup Rsyslog with MySQL and LogAnalyzer on CentOS/RHEL systems. In the first part we have integrated Rsyslog with MySQL database server, and all the logs are now saving in database. For recalling below is few configuration details which we used in part-1 to setup it.

    Rsyslog MySQL Database: Syslog
    Rsyslog MySQL Username: rsyslog
    Rsyslog MySQL Password: MYSQLPASSWORD

Let’s start the setup of LogAnalyzer on your Linux system with rsyslog database using following steps.

Step 1 – Download LogAnalyzer Source

Download the LogAnalyzer latest version from its official download site or use the following command to download 4.1.5 (Current latest version) version and extract it.

$ cd /tmp
$ wget http://download.adiscon.com/loganalyzer/loganalyzer-4.1.5.tar.gz
$ tar xzf loganalyzer-4.1.5.tar.gz

After extracting copy the required files to web server default document root as below.

$ mv loganalyzer-4.1.5/src /var/www/html/loganalyzer

Step 2 – Create Config File

Now create a blank configuration file named config.php in loganalyzer directory and setup write permission to apache user.

$ cd /var/www/html/loganalyzer
$ touch config.php
$ chown www-data:www-data config.php     # Use apache for redhat system
$ chmod 777 config.php

Step 3 – Start Loganalyzer Web Installer

After completing above steps open following url in your favorite web browser to start LogAnalyzer web installer.

http://tecadmin.net/loganalyzer/intall.php

Now follow the web installer steps as per below given screen shots.

Step 3.1: Just click Next.

install LogAnalyzer 1

Step 3.2: Make sure config.php is writable and click Next.

install LogAnalyzer 2

Step 3.3: Fill the database details for loganalyzer, we can also use same database used for Rsyslog and click Next.

install LogAnalyzer 3

Step 3.4: In this step installer will create database table, if tables already found, you will get an warning of data overwritten. We just need to click Next.

install LogAnalyzer 4

Step 3.5: This screen will show the result of table creation’s. Just click Next

install-la-5

Step 3.6: Create an Administrator account and click Next.

install-la-6

Step 3.7: Fill the Rsyslog database details and click Next.

install-la-7

Step 3.8: LogAnalyzer installation has been completed. We just need to click Finish.

install-la-8

Step 3.9: Login to LogAnalyzer using Administrator credentials created in Step 3.6.

install-la-9

Congratulation’s! on successful configuration of LogAnalyzer with Rsyslog MySQL database. Read other article to configure Rsyslog to collect logs on central server. So we can monitor all server logs at on place using LogAnalyzer.

The post How to Setup LogAnalyzer with Rsyslog and MySQL appeared first on TecAdmin.

]]>
https://tecadmin.net/setup-loganalyzer-with-rsyslog-and-mysql/feed/ 26
How to Shrink SQL Server Transaction Log Files using DBCC SHRINKFILE https://tecadmin.net/shrink-sql-server-transaction-log-files-dbcc-shrinkfile/ https://tecadmin.net/shrink-sql-server-transaction-log-files-dbcc-shrinkfile/#comments Sat, 02 Mar 2013 12:58:08 +0000 https://tecadmin.net/?p=369 Sometimes SQL Server logs files acquire a large space on the disk. In that case, we need to reduce the size of the log file to claim some space. But truncating or reducing database log file in SQL Server 2008 can be quite difficult. It also has its own issues. This article contains a set [...]

The post How to Shrink SQL Server Transaction Log Files using DBCC SHRINKFILE appeared first on TecAdmin.

]]>
Sometimes SQL Server logs files acquire a large space on the disk. In that case, we need to reduce the size of the log file to claim some space. But truncating or reducing database log file in SQL Server 2008 can be quite difficult. It also has its own issues.

This article contains a set of commands to Shrink Log Files of SQL Server database.

Generally this command is I prefer to take a backup of the database before executing below command for a safer side

Shrink SQL Server Transaction Log Files

First of all, check the actual name of log files stored in SQL server records using the following SQL query. Execute these queries in using SQL Server management studio query browser.

USE DATABASE_NAME;
GO

SELECT FILE_NAME(2);
GO

Now, use the DBCC SHRINKFILE SQL command to shrink log files. The database must be running in SIMPLE recovery mode. Open the query windows in SQL Server management studio and run the following command. You

Make sure to change DATABASE_NAME with actual database name and LOG_FILE_NAME with log file name found in the above step. The below example query will shrink the log file to 1000MB.

USE DATABASE_NAME;
GO

ALTER DATABASE DATABASE_NAME
SET RECOVERY SIMPLE;
GO  

DBCC SHRINKFILE (LOG_FILE_NAME, 1000);
GO  

ALTER DATABASE DATABASE_NAME
SET RECOVERY FULL;
GO  

All done. Now check the size of the log files, I hope you will get the expected results.

The post How to Shrink SQL Server Transaction Log Files using DBCC SHRINKFILE appeared first on TecAdmin.

]]>
https://tecadmin.net/shrink-sql-server-transaction-log-files-dbcc-shrinkfile/feed/ 1