- BOT Telegram
- Linux
You can follow this Step
- Make an simple Script
nano /usr/bin/boot
#!/bin/bash
ALERT=$(echo -e "\u26A0")
DATE=$(date)
HOSTNAME=$(hostname)
telegram "$ALERT $HOSTNAME ALREADY RUNNING on $DATE $ALERT"
chmod +x /usr/bin/boot
- Make an crontab
crontab -e
@reboot /usr/bin/boot
sudo systemctl enable cron.service
- Make Simple Script
nano /usr/bin/beforeshutdown
#!/bin/bash
ALERT=$(echo -e "\u26A0")
DATE=$(date)
HOSTNAME=$(hostname)
telegram "$ALERT $HOSTNAME are Turning to POWEROFF State on $DATE $ALERT"
chmod +x /usr/bin/beforeshutdown
- Make Systemd Service
nano /etc/systemd/system/run-before-shutdown.service
[Unit]
Description=Alert at shutdown
DefaultDependencies=no
Before=shutdown.target
[Service]
Type=oneshot
ExecStart=/usr/bin/beforeshutdown
TimeoutStartSec=0
[Install]
WantedBy=shutdown.target
systemctl daemon-reload
systemctl enable run-before-shutdown.service