Skip to content

Instantly share code, notes, and snippets.

View ayozehd's full-sized avatar

Ayoze Hernández ayozehd

View GitHub Profile
@ayozehd
ayozehd / docker_clean_logs.sh
Created September 20, 2020 11:23
Clean all docker containers logs
#!/bin/bash
# Run this script as ROOT
# Display docker logs disk usage in human-readable
du -chs /var/lib/docker/containers/*/*json.log;
# Clean all docker logs
truncate -s 0 /var/lib/docker/containers/*/*-json.log;
#!/bin/bash
# https://stackoverflow.com/a/47609921/1497139
# Usage corstest -v http://example.com
#ansi colors
#http://www.csc.uvic.ca/~sae/seng265/fall04/tips/s265s047-tips/bash-using-colors.html
blue='\033[0;34m'
red='\033[0;31m'
green='\033[0;32m' # '\e[1;32m' is too bright for white bg.
endColor='\033[0m'
@ayozehd
ayozehd / backup-files.sh
Created June 18, 2018 13:25
Backup compressing your files from a directory. Useful to run from Cron.d
#!/bin/bash
DATE="$(date '+%d.%m.%Y')"
ALLPROJECTSDIR='/var/www/html' || $3; # Type you projects folder. It could be /home/user/public_html
PROJECT=$1 # Project's Name is needed as script argument!
PROJECTDIR="$ALLPROJECTSDIR/$PROJECT"
BACKUPDIR="$HOME/backup" || $2
PROJECTBACKUPDIR="$BACKUPDIR/$PROJECT"
CAPACITYLIMIT=95 # Setup your capacity limit
CURRENTCAPACITY=$(df -h $BACKUPDIR | tail -1 | awk '{print $5}' | cut -d '%' -f 1)
LOGFILE="$HOME/log/backup-files-$PROJECT.log"