Knowledge Base
KamlatechToolBlogContact Us
  • Kamlatech Documentation
  • Magento
    • Installation
    • Email Configuration
  • Blogger
    • Adding Code Block
  • Linux
    • Managing Logs
    • Prevent Package Update
  • Node
    • Installation
    • Http-Server
  • Github
    • .gitignore
    • Branch to New Repo
  • HTML
    • Common Header & Footer in HTML
  • Linkedin Infographics
    • Flame Retardant Standards
    • Flame Retardant Terms
  • Music
    • Pandit Niladri Kumar - Sitar
  • Applications
    • Konvect Connect
    • Konvect Fetcher
    • Konvect Fetcher WebApp
  • HTTPS SSL Certificate
    • Lets's Encrypt
  • Oracle Cloud Instance
    • Firewall
    • CPU Stressing
    • CPU Stressing Docker
  • SFTP
    • WinSCP SFTP
  • NextCloud
    • Installation
    • Post Install Tweak
    • PHP Version
  • Wordpress
    • NGINX Configuration
    • Image upload / Crop issue
    • Required PHP Modules
    • PHP Configuration
  • Healthcare Wearables (Cardiac)
    • Wearable ECG
    • Arrhythmia
    • Ambulatory ECG Usecase
    • Understanding EKG Leads
  • Flutter
    • Direct URL Access
    • Change Android PackageName
  • Math
    • Online Equation Writing
  • Backend Web Service
    • Flask App Deployment
  • 3D Modeling
    • DWG in Solid Edge
  • MariaDB
    • MariaDB Commands
  • Excel
    • HTML as String in Excel
  • Tools
    • Online Tools
  • PostgreSQL
    • PostgreSQL Installation
  • MEDUSA
    • Medusa Installation
    • Backend Server/Worker Mode
    • Frontend Deployment
  • Jupyter Lab
    • Jupyter Web App
  • WooCommerce
    • Product Filename Renaming
  • Embedded
    • Flash Xiao Sense Bootloader
Powered by GitBook
On this page
Edit on GitHub
  1. Linux

Managing Logs

PreviousAdding Code BlockNextPrevent Package Update

Last updated 1 year ago

Sometimes if the Linux installation is behaving oddly, it generate a heap of logs. This can quickly fill up your storage space. I encountered this issue when using Linux on android via linuxdeploy.

Here is the command for checking the log size in Linux. This command will list the top 10 log files based on its size (large to small). This is in Debian system.

sudo du -ah /var/log | sort -h -r | head -n 10

Output may look like this

2.1M    /var/log
512K    /var/log/nginx
508K    /var/log/auth.log.1
288K    /var/log/dpkg.log.1
240K    /var/log/nginx/access.log
136K    /var/log/letsencrypt
96K     /var/log/nginx/access.log.1
88K     /var/log/apt
72K     /var/log/auth.log.2.gz
56K     /var/log/bootstrap.log

You can always open and study the logs to understand the problems. Or you can delete them using this command. Here we are deleting nginx logs with the size 512K.

echo "" > /var/log/nginxbash

You can also create a script to automatically delete the log at certain interval, like a day or every 12 hours. Here is an example script file. You can modify the script based on the log files you want to clear.

Place the script file (logerase.sh) at /usr/local/bin.

Give execute permission to the script via this command

chmod +x /usr/local/bin/logerase.sh

Automate the script execution via Crontab

sudo crontab -e

Add the following line in crontab to execute the script daily at 00:00

0 0 * * * /usr/local/bin/logerase.sh

cloudflare-update/logerase.sh at main · prashant3285/cloudflare-updateGitHub
Logo