Skip to content

Instantly share code, notes, and snippets.

@hieunt79
Last active November 26, 2020 06:45
Show Gist options
  • Save hieunt79/695247aec5845a3f4887fe520dd42346 to your computer and use it in GitHub Desktop.
Save hieunt79/695247aec5845a3f4887fe520dd42346 to your computer and use it in GitHub Desktop.
Linux scripts
#!/bin/bash
cd /tmp
ip_list="$@"
while true
clear
tput cup 0 0
do
for ip in $ip_list
do
echo "===== $ip:443 ====";
cat $ip-responses-https-hieunt79;
echo "===== $ip:80 ====";
cat $ip-responses-hieunt79;
done
sleep 1
done
#!/bin/bash
# use for healthcheck wp_core
#
# Add to crontab: * * * * * /crontab-scripts/healthcheck.sh > /dev/null
DIRECTORY="/var/log/healthcheck"
CURRENTDAY=`date "+%m-%d-%Y"`
WPIP="x.x.x.x"
if [ ! -d "$DIRECTORY" ]; then
# Control will enter here if $DIRECTORY doesn't exist.
mkdir -p $DIRECTORY
fi
function test_curl {
CURRENTTIME=`date`
echo $CURRENTTIME >> $DIRECTORY/$CURRENTDAY.log
timeout 5s curl $WPIP >> $DIRECTORY/$CURRENTDAY.log
echo >> $DIRECTORY/$CURRENTDAY.log
}
test_curl
sleep 10s
test_curl
sleep 10s
test_curl
sleep 10s
test_curl
#!/bin/bash
# use for logging memnory of Linux machine daily
#
# Add to crontab: * * * * * /crontab-scripts/memory-usage-log.sh > /dev/null
DIRECTORY="/var/log/memory_usage"
CURRENTDAY=`date "+%m-%d-%Y"`
CURRENTTIME=`date`
if [ ! -d "$DIRECTORY" ]; then
# Control will enter here if $DIRECTORY doesn't exist.
mkdir -p $DIRECTORY
fi
echo $CURRENTTIME >> $DIRECTORY/$CURRENTDAY.log
free -hm >> $DIRECTORY/$CURRENTDAY.log
echo >> $DIRECTORY/$CURRENTDAY.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment