четверг, 3 октября 2024 г.

Bash check process status and restarting

 #!/bin/bash

PROCESS_NAME="queue:consumers:start specificName"

START_COMMAND="/usr/bin/php8.2 /var/www/project/html/bin/magento queue:consumers:start specificName --single-thread --max-messages=20000"


pgrep -f "$PROCESS_NAME" > /dev/null

PGREP_STATUS=$?


# 0 - found, 1 - not found

if [ $PGREP_STATUS -ne 0 ]; then

    echo "$(date '+%Y-%m-%d %H:%M:%S') - The process $PROCESS_NAME wasn't found, restarting..."

    $START_COMMAND &

    pgrep -af "PROCESS_NAME"

fi

четверг, 26 сентября 2024 г.

Siege with Basic Http Auth

 https://gist.github.com/rob-murray/dd77778b1770f32c46e8

# Basic auth;

auth=$(echo -n 'username:password' | openssl base64)

siege -t60s -c20 -d10 --header="Authorization:Basic $auth" 'https://staging.a-hostname.co.uk/'

siege -f sitemap.txt -c100 -t15m -d7 -iv --no-parser --header="Authorization:Basic $auth" -m "Project siege Sep 26 2024" -l  


пятница, 9 августа 2024 г.

550 5.7.64 TenantAttribution; Relay Access Denied [No TLS]

 Troubleshooting:

1) create/enable 'Connector' in 'Exchange'

Show all > Exchange > EAC (Exchange Administrative Control) > Mail flow > Connectors

2) check into created connector if enabled an option like 'keep Exchange headers'

четверг, 18 апреля 2024 г.

Linux Bash rsync remote to remote with forwarding keys

We need it for loading files directly from one remote server to another one where we have SSH access.

SSH access from a Workstation -> Server1 -> rsync loading files -> Server2

ssh -v username@server1

find an identity SSH key for sure

ssh-add <the_key>

ssh -A username@server1

run with A option for allowing forwarding keys 

rsync -azP --exclude '.4y8-folder' --exclude 'file.tar.gz' pub/media/ username@server2:pub/media/

среда, 14 июня 2023 г.

Linux Bash remove old files more than 10 if exists

if [ $(expr $(ls -1 /test/111 | wc -l | tr -d ' ')) -gt 10 ]; then rm $(ls -d -1 -At /test/111/* | tail -n $(expr $(ls -1 /test/111 | wc -l | tr -d ' ') - 10)) ; fi 

to crontab

/bin/bash -c "if [ $(expr $(ls -1 /test/111 | wc -l | tr -d ' ')) -gt 10 ]; then rm $(ls -d -1 -At /test/111/* | tail -n $(expr $(ls -1 /test/111 | wc -l | tr -d ' ') - 10)) ; fi"

среда, 24 мая 2023 г.

Linux Bash rsync only specific a files list

Check rsync --help whether it supports --files-from= option 

lst content

./folder-source/1/1

./folder-source/2/2

...

cd to a folder where folder-source as a sub-folder (it's an explanation of period "." in rsync command)

rsync --files-from=/tmp/lst . /app/var/folder-sync