Sending Alert Mail on Shutdown and Boot up!
Hello! In this time, I want to run an custom application as a service on my LINUX and want to run with specific user to follow some security policies. Can customize your actionable scripts with this if your are working on systemd related machines. Need to be running Postfix service before the demonstration! So let me into demonstration about sending system shutdown and startup alert mail to system administrator. I intend this to let system admin know as a proof of machine power state in an incident. Firstly, must have actionable script or application that you want to run. demo use mail command as a service. I have two scripts. one for system up and one or system down. startupmail.sh was as follow: #!/bin/bash DATE=$(date '+%Y-%m-%d %H:%M:%S') $(mail -s "$HOSTNAME - System Start" exampleuser@example.com <<< "$HOSTNAME was started at $DATE") shutdownmail.sh was as follow: #!/bin/bash DATE=$(date '+%Y-%m-%d %H:%M:%S'