systemd, send an email after restart
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I am using systemd to autolaunch a service with the following script: (see below)
I am trying to send an email before the service is started (the commented out line).
the link at the end of the line /home/vincent/wintergreen/service_files/IB_restart_email
is the content of the email, as described here in paragraph 7.
Unit]
Description=Manages an instance of IBController
[Service]
Type=forking
User=vincent
Group=vincent
ExecStart=/bin/bash -c "cd /opt/IBController && bash IBControllerStart.sh -inline && sleep 10"
# ExecStartPre=/usr/bin/mail -s "Restarting TWS" me@gmail.com < /home/vincent/wintergreen/service_files/IB_restart_email
Environment=DISPLAY=:0.0
KillMode=control-group
TimeoutSec=0
Restart=always
[Install]
WantedBy=graphical.target
However, this line returns the error mail: Cannot parse address <' (while expanding <'): Malformed email address
. (i can see the error message when opening the journalctl)
This command works when used directly in the shell. Anyone has an idea how to make this mail sending line work when used from the systemd file?
PS: I am using postfix
for the mail sending
linux systemd email
add a comment |Â
up vote
0
down vote
favorite
I am using systemd to autolaunch a service with the following script: (see below)
I am trying to send an email before the service is started (the commented out line).
the link at the end of the line /home/vincent/wintergreen/service_files/IB_restart_email
is the content of the email, as described here in paragraph 7.
Unit]
Description=Manages an instance of IBController
[Service]
Type=forking
User=vincent
Group=vincent
ExecStart=/bin/bash -c "cd /opt/IBController && bash IBControllerStart.sh -inline && sleep 10"
# ExecStartPre=/usr/bin/mail -s "Restarting TWS" me@gmail.com < /home/vincent/wintergreen/service_files/IB_restart_email
Environment=DISPLAY=:0.0
KillMode=control-group
TimeoutSec=0
Restart=always
[Install]
WantedBy=graphical.target
However, this line returns the error mail: Cannot parse address <' (while expanding <'): Malformed email address
. (i can see the error message when opening the journalctl)
This command works when used directly in the shell. Anyone has an idea how to make this mail sending line work when used from the systemd file?
PS: I am using postfix
for the mail sending
linux systemd email
Have you try in formatcat /home/vincent/wintergreen/service_files/IB_restart_email|/usr/bin/mail -s "Restarting TWS" me@gmail.com
because<
symbol is user as part of email address
â Romeo Ninov
May 16 at 16:31
1
You used/bin/bash -c ...
for theExecStart
, so why not also for theExecStartPre
line?
â thrig
May 16 at 16:41
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am using systemd to autolaunch a service with the following script: (see below)
I am trying to send an email before the service is started (the commented out line).
the link at the end of the line /home/vincent/wintergreen/service_files/IB_restart_email
is the content of the email, as described here in paragraph 7.
Unit]
Description=Manages an instance of IBController
[Service]
Type=forking
User=vincent
Group=vincent
ExecStart=/bin/bash -c "cd /opt/IBController && bash IBControllerStart.sh -inline && sleep 10"
# ExecStartPre=/usr/bin/mail -s "Restarting TWS" me@gmail.com < /home/vincent/wintergreen/service_files/IB_restart_email
Environment=DISPLAY=:0.0
KillMode=control-group
TimeoutSec=0
Restart=always
[Install]
WantedBy=graphical.target
However, this line returns the error mail: Cannot parse address <' (while expanding <'): Malformed email address
. (i can see the error message when opening the journalctl)
This command works when used directly in the shell. Anyone has an idea how to make this mail sending line work when used from the systemd file?
PS: I am using postfix
for the mail sending
linux systemd email
I am using systemd to autolaunch a service with the following script: (see below)
I am trying to send an email before the service is started (the commented out line).
the link at the end of the line /home/vincent/wintergreen/service_files/IB_restart_email
is the content of the email, as described here in paragraph 7.
Unit]
Description=Manages an instance of IBController
[Service]
Type=forking
User=vincent
Group=vincent
ExecStart=/bin/bash -c "cd /opt/IBController && bash IBControllerStart.sh -inline && sleep 10"
# ExecStartPre=/usr/bin/mail -s "Restarting TWS" me@gmail.com < /home/vincent/wintergreen/service_files/IB_restart_email
Environment=DISPLAY=:0.0
KillMode=control-group
TimeoutSec=0
Restart=always
[Install]
WantedBy=graphical.target
However, this line returns the error mail: Cannot parse address <' (while expanding <'): Malformed email address
. (i can see the error message when opening the journalctl)
This command works when used directly in the shell. Anyone has an idea how to make this mail sending line work when used from the systemd file?
PS: I am using postfix
for the mail sending
linux systemd email
asked May 16 at 15:38
jim basquiat
1417
1417
Have you try in formatcat /home/vincent/wintergreen/service_files/IB_restart_email|/usr/bin/mail -s "Restarting TWS" me@gmail.com
because<
symbol is user as part of email address
â Romeo Ninov
May 16 at 16:31
1
You used/bin/bash -c ...
for theExecStart
, so why not also for theExecStartPre
line?
â thrig
May 16 at 16:41
add a comment |Â
Have you try in formatcat /home/vincent/wintergreen/service_files/IB_restart_email|/usr/bin/mail -s "Restarting TWS" me@gmail.com
because<
symbol is user as part of email address
â Romeo Ninov
May 16 at 16:31
1
You used/bin/bash -c ...
for theExecStart
, so why not also for theExecStartPre
line?
â thrig
May 16 at 16:41
Have you try in format
cat /home/vincent/wintergreen/service_files/IB_restart_email|/usr/bin/mail -s "Restarting TWS" me@gmail.com
because <
symbol is user as part of email addressâ Romeo Ninov
May 16 at 16:31
Have you try in format
cat /home/vincent/wintergreen/service_files/IB_restart_email|/usr/bin/mail -s "Restarting TWS" me@gmail.com
because <
symbol is user as part of email addressâ Romeo Ninov
May 16 at 16:31
1
1
You used
/bin/bash -c ...
for the ExecStart
, so why not also for the ExecStartPre
line?â thrig
May 16 at 16:41
You used
/bin/bash -c ...
for the ExecStart
, so why not also for the ExecStartPre
line?â thrig
May 16 at 16:41
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
2
down vote
accepted
As documented in man systemd.service
, systemd has a limited support for shell syntax, which does not include "<". So, the character is set to the "mail" command, resulting in this error.
I presume you are most interested in emails due to automatic restarts, which wold be due to service crashes.
For that, the OnFailure=
directive is a better choice. Use it to provide a spaces-separated list of units that are activated when the unit enters the failed state.
There are already ready-made solutions to handle this, like this one which will email you the "status" output (including some log output) of the service when it fails.
Also, consider using the WorkingDirectory=
directive instead of manually calling "cd" in ExecStart=
.
It also not clear why "sleep 10" would be needed as part of starting the app.
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
As documented in man systemd.service
, systemd has a limited support for shell syntax, which does not include "<". So, the character is set to the "mail" command, resulting in this error.
I presume you are most interested in emails due to automatic restarts, which wold be due to service crashes.
For that, the OnFailure=
directive is a better choice. Use it to provide a spaces-separated list of units that are activated when the unit enters the failed state.
There are already ready-made solutions to handle this, like this one which will email you the "status" output (including some log output) of the service when it fails.
Also, consider using the WorkingDirectory=
directive instead of manually calling "cd" in ExecStart=
.
It also not clear why "sleep 10" would be needed as part of starting the app.
add a comment |Â
up vote
2
down vote
accepted
As documented in man systemd.service
, systemd has a limited support for shell syntax, which does not include "<". So, the character is set to the "mail" command, resulting in this error.
I presume you are most interested in emails due to automatic restarts, which wold be due to service crashes.
For that, the OnFailure=
directive is a better choice. Use it to provide a spaces-separated list of units that are activated when the unit enters the failed state.
There are already ready-made solutions to handle this, like this one which will email you the "status" output (including some log output) of the service when it fails.
Also, consider using the WorkingDirectory=
directive instead of manually calling "cd" in ExecStart=
.
It also not clear why "sleep 10" would be needed as part of starting the app.
add a comment |Â
up vote
2
down vote
accepted
up vote
2
down vote
accepted
As documented in man systemd.service
, systemd has a limited support for shell syntax, which does not include "<". So, the character is set to the "mail" command, resulting in this error.
I presume you are most interested in emails due to automatic restarts, which wold be due to service crashes.
For that, the OnFailure=
directive is a better choice. Use it to provide a spaces-separated list of units that are activated when the unit enters the failed state.
There are already ready-made solutions to handle this, like this one which will email you the "status" output (including some log output) of the service when it fails.
Also, consider using the WorkingDirectory=
directive instead of manually calling "cd" in ExecStart=
.
It also not clear why "sleep 10" would be needed as part of starting the app.
As documented in man systemd.service
, systemd has a limited support for shell syntax, which does not include "<". So, the character is set to the "mail" command, resulting in this error.
I presume you are most interested in emails due to automatic restarts, which wold be due to service crashes.
For that, the OnFailure=
directive is a better choice. Use it to provide a spaces-separated list of units that are activated when the unit enters the failed state.
There are already ready-made solutions to handle this, like this one which will email you the "status" output (including some log output) of the service when it fails.
Also, consider using the WorkingDirectory=
directive instead of manually calling "cd" in ExecStart=
.
It also not clear why "sleep 10" would be needed as part of starting the app.
answered May 16 at 16:59
Mark Stosberg
3,4891023
3,4891023
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f444179%2fsystemd-send-an-email-after-restart%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Have you try in format
cat /home/vincent/wintergreen/service_files/IB_restart_email|/usr/bin/mail -s "Restarting TWS" me@gmail.com
because<
symbol is user as part of email addressâ Romeo Ninov
May 16 at 16:31
1
You used
/bin/bash -c ...
for theExecStart
, so why not also for theExecStartPre
line?â thrig
May 16 at 16:41