Let me preface this my saying I am a Linux noob, so apologies for anything that should be painfully obvious but i'm not getting it.
I have a phone server running on Debian, this phone server is supposed to send out emails when services crash, but this isn't always reliable, sometimes the services crash and we are never notified. So I figured it would be more reliable to have the services trigger an alert in the OS itself to send a notification if they go down, instead of at the software level.
I have a total of three different files, one is a bash script, one is a text file with the email parameters, and the other is the service.
The bash script (called systemd-email.sh) has this in it:
#!/bin/bash sendmail -vt < mail.txt The file the script references above (mail.txt) has this in it (some info changed to generic):
To: [email protected] From: [email protected] Subject: A Service Has Failed A service has failed, please login to PBX and confirm all services are working and investigate failure. The service has this in it (root is there only for testing, will change to user created for this service if I can get it working):
[Unit] Description=Status email for PBX services to support [Service] Type=oneshot ExecStart=/bin/bash /usr/local/bin/systemd-email.sh User=root Group=systemd-journal If I run the bash script directly it works just fine. When I try to start the service it says that it failed because the control process exited with an error code. I am attempting to start the service using "sudo sytemctl start status-email.service".
If I run "sudo systemctl status status-email.service" I get the output shown in the attached screenshot.
Any help is appreciated. Thanks.

mail.txtfile. The script isn't running in the directory that contains the file.mail.txtfile. So it should be obvious that it's looking in the wrong directory.