BASH_SRV Telegram 122
🔥 Автоматическая проверка и перезапуск упавших сервисов

Скрипт, который проверяет список сервисов и перезапускает их при необходимости.


#!/bin/bash
# автор: https://www.tgoop.com/bash_srv

# Список сервисов для проверки
services=("nginx" "mysql" "ssh")

for service in "${services[@]}"; do
if ! systemctl is-active --quiet "$service"; then
echo "$(date '+%Y-%m-%d %H:%M:%S') - $service не работает. Перезапускаем..."
systemctl restart "$service"
# Можно отправить уведомление в Telegram или email
else
echo "$(date '+%Y-%m-%d %H:%M:%S') - $service работает."
fi
done


📌 Как использовать:

1. Сохраните скрипт, например, в /usr/local/bin/service_check.sh.
2. Дайте права на выполнение:


chmod +x /usr/local/bin/service_check.sh

3. Добавьте в cron для регулярной проверки, например, каждые 5 минут:


*/5 * * * * /usr/local/bin/service_check.sh >> /var/log/service_check.log 2>&1


👉@bash_srv
👍9



tgoop.com/bash_srv/122
Create:
Last Update:

🔥 Автоматическая проверка и перезапуск упавших сервисов

Скрипт, который проверяет список сервисов и перезапускает их при необходимости.


#!/bin/bash
# автор: https://www.tgoop.com/bash_srv

# Список сервисов для проверки
services=("nginx" "mysql" "ssh")

for service in "${services[@]}"; do
if ! systemctl is-active --quiet "$service"; then
echo "$(date '+%Y-%m-%d %H:%M:%S') - $service не работает. Перезапускаем..."
systemctl restart "$service"
# Можно отправить уведомление в Telegram или email
else
echo "$(date '+%Y-%m-%d %H:%M:%S') - $service работает."
fi
done


📌 Как использовать:

1. Сохраните скрипт, например, в /usr/local/bin/service_check.sh.
2. Дайте права на выполнение:


chmod +x /usr/local/bin/service_check.sh

3. Добавьте в cron для регулярной проверки, например, каждые 5 минут:


*/5 * * * * /usr/local/bin/service_check.sh >> /var/log/service_check.log 2>&1


👉@bash_srv

BY Bash Советы




Share with your friend now:
tgoop.com/bash_srv/122

View MORE
Open in Telegram


Telegram News

Date: |

How to create a business channel on Telegram? (Tutorial) The SUCK Channel on Telegram, with a message saying some content has been removed by the police. Photo: Telegram screenshot. Telegram has announced a number of measures aiming to tackle the spread of disinformation through its platform in Brazil. These features are part of an agreement between the platform and the country's authorities ahead of the elections in October. The group also hosted discussions on committing arson, Judge Hui said, including setting roadblocks on fire, hurling petrol bombs at police stations and teaching people to make such weapons. The conversation linked to arson went on for two to three months, Hui said. As the broader market downturn continues, yelling online has become the crypto trader’s latest coping mechanism after the rise of Goblintown Ethereum NFTs at the end of May and beginning of June, where holders made incoherent groaning sounds and role-played as urine-loving goblin creatures in late-night Twitter Spaces.
from us


Telegram Bash Советы
FROM American