This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Statement": [ | |
{ | |
"Effect": "Allow", | |
"Action": [ | |
"ec2:DescribeInstances", | |
"ec2:DescribeTags" | |
], | |
"Resource": "*" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
## Convert 'this/is a:string 123' to THIS_IS_A_STRING_123 | |
## | |
# converting a hard coded string to all uppercase with underscoree | |
echo "this/is a:string 123" | iconv -t ascii//TRANSLIT | sed -r s/[^a-zA-Z0-9]+/_/g | sed -r s/^-+\|-+$//g | tr a-z A-Z | |
# output: THIS_IS_A_STRING_123 | |
# using variables variable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PROXY_USER=... | |
PROXY_PASS=.... | |
PROXY_IP=185.XXX.XXX.XXX | |
PROXY_PORT=37257 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
``` | |
user='USER' | |
pname='php-fpm' | |
# get total memory usage of php-fpm | |
ps -U $user --no-headers -o rss -o command | grep $pname | awk '{ sum+=$1} END {print int(sum/1024) "MB"}' | |
# get total number of php-fpm processes + 1 | |
ps aux | grep $pname | wc -l |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Count IP's and sort in nginx access log | |
from: https://www.mkyong.com/nginx/count-ip-address-in-nginx-access-logs/ | |
``` | |
sudo awk '{print $1}' /var/log/nginx/access.log | sort | uniq -c | sort -nr | |
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# Delete backup more than 90 days old. | |
# | |
backupDir="/var/lib/psa/dumps/tmp" | |
# | |
daysToKeep=90 | |
echo "Checking for files older than $daysToKeep days in $backupDir" | |
listOfFiles=`find $backupDir -mtime +$daysToKeep` |
NewerOlder