#linux #services #service #systemctl #debian #ubuntu
Create a linux service
Create sh file:
/usr/sbin/hostonline.sh
#!/bin/bash
dt=$(date '+%d/%m/%Y %H:%M:%S');
# echo "$dt"
curl "https://api.telegram.org/bot5517742533:AAHkL0Ea3ueHKRuWw2oCsVPmcgFDH0lMj84/sendmessage?chat_id=1591506805&text=$dt+openvpn+is+online!"
Create service file
/etc/systemd/system/hostonline.service
[Unit]
Description=Host Online Notifier
After=network.target
[Service]
Type=simple
ExecStart=/bin/bash /usr/sbin/hostonline.sh
TimeoutStartSec=0
[Install]
WantedBy=default.target
--------------
systemctl daemon-reload
systemctl enable hostonline.service
Confirm that your test service was created successfully:
systemctl --all | grep hostonline.service
Start your Service
systemctl start hostonline.service
Test it by performing a reboot
Zie ook [[Controlling Linux Services Daemons]]