• Pular para navegação primária
  • Skip to main content
  • Home
  • Sobre/About
  • Projetos
  • Blog

Celso Bessa (sɛwsʊ bɛ:sa)

Prefiro construir pontes a muros

Linux

Quick tip: Managing disk space on Linux Ubuntu 1: beware of systemd journal logs and backups

7 março, 2021 por Celso Bessa

A quick-but-not-so-quick tip for Linux users: beware of systemd journal logs and backup.

Recently, I had a server running out of space often and because of that, MySQL and other services crashing. When checking the reason, I found out that both systemd journal logs and one of the servers websites backups were hogging disk space.

Cleaning up systemd journal logs space with journalctl

In the case of systemd journal logs, it’s a good “system hygiene” to clean it up often. Just don’t clean it up too much, because Logs are useful for security audits.

To do that, just use the journalctl command with the either the --vacuum-time or --vacuum-size parameters with a sensible setting. The first one will clean the journal logs and leave just the ones from the time set. For example, journalctl –vacuum-time=6months will keep only the lost from the last 6 months. The seconde one will clean logs until it achieves the specified size. That is, journalctl --vacuum-size=500M will keep only 500 megabytes of data.

For more information on how journalctl, a great tool, works check its manual page: https://www.man7.org/linux/man-pages/man1/journalctl.1.html

Make sure you delete old sites backups.

Another often overlooked reason for running out of disk space is old backups not being deleted. Specially when you have some sort of automatic backup in place (e.g. using cron jobs) but they are not automatically deleted. In my case, one of the cron jobs to delete old backups of a client website were not properly set and it was not working. So, remember to check your backups often and make sure all your cron jobs are working properly.

Arquivado em: blog Marcados com as tags: devops, Linux, technology, Ubuntu 20.04, web development

Linux/MacOs tip: use du to check folder and files sizes (disk usage)

29 dezembro, 2020 por Celso Bessa

Whenever you are using terminal on Unix, Linux and MacOs and need to check the amount of space used by a folder or files, you can use the `du` command:

// basic use. Gives the size in bytes of all files and folders in the folder you are in
du

// gives the size in "human readable" units like kilobytes, megabytes, gigabytes of all files and folders.
du -h

// gives an one line summary of the space occupied by all files and folders
du -s

// combines human readable and summary options
du -hs

Arquivado em: blog Marcados com as tags: Linux, MacOs, technology, tecnologia

Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (exceto fotografias com produto de terceiros ou pessoas)
Otimizado pela WoWPerations e hospedado na Digital Ocean
(Assinando Digital Ocean através deste link do programa indicação, você ganha crédito de 100 dólares para serem utilizados em até 60 dias, e eu ganho uma pequena comissão)