Useful commands

Useful commands and scripts that simplify technical tasks, like managing logs using Notepad++ with regex or automating DNS checks for domains.

a year ago   •   1 min read

By Remco Loup.
Photo by Ugi K. / Unsplash
Table of contents

Notepad++ regexp

For example checking your php-fpm access/slow log file. Use mark in notepad++ to mark all lines that are slower then x/y.

10000ms en trager 

^.*\s(\d{5,}\.\d{3}ms).*

5000ms en trager 

^.*\s(5\d{3}\.\d{2,}ms|\d{5,}\.\d{2,}ms).*

DNS tools to automatically check the transfer of your DNS

sudo apt update
sudo apt install dnsutil

nano check_nameservers.sh
#!/bin/bash

DOMAIN="jouwdomein.com"
EXPECTED_NS1="ns1.cloudflare.com."
EXPECTED_NS2="ns2.cloudflare.com."

# Get the current nameservers
CURRENT_NS=$(dig NS $DOMAIN +short)

# Check if the current nameservers match the expected ones
if [[ $CURRENT_NS == *"$EXPECTED_NS1"* && $CURRENT_NS == *"$EXPECTED_NS2"* ]]; then
    echo "Nameservers are correctly set to Cloudflare."
else
    echo "Nameservers have not yet switched to Cloudflare."
fi
chmod +x check_nameservers.sh

watch -n 1 ./check_nameservers.sh

Spread the word

Keep reading