Why does my mailing script work outside of rc.local but not when I run rc.local?





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







1















I have ubuntu 18.04 and I recently added the rc.local script to /etc/ so I could run my emailing script to email myself my IP address from my jetson nano computer. I need it to email me because I cannot setup a static IP and the IP changes occasionally. The computer will be setup on a 1:16 RC race car so I have to ssh into it.



I used this tutorial to setup ssmtp on ubuntu: https://stackoverflow.com/questions/38391412/raspberry-pi-send-mail-from-command-line-using-gmail-smtp-server



I used this tutorial to attempt to run the script I show below on startup on ubuntu 18.04: https://www.linuxbabe.com/linux-server/how-to-enable-etcrc-local-with-systemd



This is my emailIP.sh :



#!/bin/bash
STR="$(/sbin/ifconfig)"

echo "$STR" | ssmtp my.email@gmail.com


It is a very simple script and it works when i run it using sh emailIP.sh



When I run sudo systemctl start rc-local.service and then run sudo systemctl status rc-local.service



I get this output:



 ● rc-local.service - /etc/rc.local Compatibility
Loaded: loaded (/etc/systemd/system/rc-local.service; enabled; vendor preset: enabled)
Drop-In: /lib/systemd/system/rc-local.service.d
└─debian.conf
Active: active (exited) since Sat 2019-03-23 14:45:28 CDT; 15min ago
Process: 4391 ExecStart=/etc/rc.local start (code=exited, status=0/SUCCESS)

Mar 23 14:45:28 servanh-desktop systemd[1]: Starting /etc/rc.local Compatibility...
Mar 23 14:45:28 servanh-desktop rc.local[4391]: ssmtp: Cannot open smtp.gmail.com:587
Mar 23 14:45:28 servanh-desktop sSMTP[4497]: Unable to locate smtp.gmail.com
Mar 23 14:45:28 servanh-desktop sSMTP[4497]: Cannot open smtp.gmail.com:587
Mar 23 14:45:28 servanh-desktop systemd[1]: Started /etc/rc.local Compatibility.


So what I am not understanding is why it is giving me this Unable to locate smtp.gmail.com error when its in my /etc/ssmtp/ssmtp.conf and if that file was not configured correctly then my script would not run when I do sh emailIP.sh?



Edit: Me sad










share|improve this question

























  • Perhaps the required network services (name resolution in particular) are not ready at that time?

    – steeldriver
    Mar 23 at 21:12











  • Would that still be a problem if I test rc.local while my device is already booted? Does 'sudo systemctl start rc-local.service' recreate boot sequence?

    – Dayman
    Mar 23 at 21:24













  • Hmm... that's a good point - I must admit I read your question quickly and assumed the output was from the bootime journal. I don't know what happens when the rc-local service is started later.

    – steeldriver
    Mar 23 at 21:45











  • Don't worry I sometimes read over too fast too. Thank you for taking a look I really do appreciate it.

    – Dayman
    Mar 23 at 21:49











  • The same error message, "ssmtp: Cannot open..." was discussed in This question. You might check to see if any of the comments or answers apply to your situation.

    – John1024
    Mar 23 at 23:50


















1















I have ubuntu 18.04 and I recently added the rc.local script to /etc/ so I could run my emailing script to email myself my IP address from my jetson nano computer. I need it to email me because I cannot setup a static IP and the IP changes occasionally. The computer will be setup on a 1:16 RC race car so I have to ssh into it.



I used this tutorial to setup ssmtp on ubuntu: https://stackoverflow.com/questions/38391412/raspberry-pi-send-mail-from-command-line-using-gmail-smtp-server



I used this tutorial to attempt to run the script I show below on startup on ubuntu 18.04: https://www.linuxbabe.com/linux-server/how-to-enable-etcrc-local-with-systemd



This is my emailIP.sh :



#!/bin/bash
STR="$(/sbin/ifconfig)"

echo "$STR" | ssmtp my.email@gmail.com


It is a very simple script and it works when i run it using sh emailIP.sh



When I run sudo systemctl start rc-local.service and then run sudo systemctl status rc-local.service



I get this output:



 ● rc-local.service - /etc/rc.local Compatibility
Loaded: loaded (/etc/systemd/system/rc-local.service; enabled; vendor preset: enabled)
Drop-In: /lib/systemd/system/rc-local.service.d
└─debian.conf
Active: active (exited) since Sat 2019-03-23 14:45:28 CDT; 15min ago
Process: 4391 ExecStart=/etc/rc.local start (code=exited, status=0/SUCCESS)

Mar 23 14:45:28 servanh-desktop systemd[1]: Starting /etc/rc.local Compatibility...
Mar 23 14:45:28 servanh-desktop rc.local[4391]: ssmtp: Cannot open smtp.gmail.com:587
Mar 23 14:45:28 servanh-desktop sSMTP[4497]: Unable to locate smtp.gmail.com
Mar 23 14:45:28 servanh-desktop sSMTP[4497]: Cannot open smtp.gmail.com:587
Mar 23 14:45:28 servanh-desktop systemd[1]: Started /etc/rc.local Compatibility.


So what I am not understanding is why it is giving me this Unable to locate smtp.gmail.com error when its in my /etc/ssmtp/ssmtp.conf and if that file was not configured correctly then my script would not run when I do sh emailIP.sh?



Edit: Me sad










share|improve this question

























  • Perhaps the required network services (name resolution in particular) are not ready at that time?

    – steeldriver
    Mar 23 at 21:12











  • Would that still be a problem if I test rc.local while my device is already booted? Does 'sudo systemctl start rc-local.service' recreate boot sequence?

    – Dayman
    Mar 23 at 21:24













  • Hmm... that's a good point - I must admit I read your question quickly and assumed the output was from the bootime journal. I don't know what happens when the rc-local service is started later.

    – steeldriver
    Mar 23 at 21:45











  • Don't worry I sometimes read over too fast too. Thank you for taking a look I really do appreciate it.

    – Dayman
    Mar 23 at 21:49











  • The same error message, "ssmtp: Cannot open..." was discussed in This question. You might check to see if any of the comments or answers apply to your situation.

    – John1024
    Mar 23 at 23:50














1












1








1








I have ubuntu 18.04 and I recently added the rc.local script to /etc/ so I could run my emailing script to email myself my IP address from my jetson nano computer. I need it to email me because I cannot setup a static IP and the IP changes occasionally. The computer will be setup on a 1:16 RC race car so I have to ssh into it.



I used this tutorial to setup ssmtp on ubuntu: https://stackoverflow.com/questions/38391412/raspberry-pi-send-mail-from-command-line-using-gmail-smtp-server



I used this tutorial to attempt to run the script I show below on startup on ubuntu 18.04: https://www.linuxbabe.com/linux-server/how-to-enable-etcrc-local-with-systemd



This is my emailIP.sh :



#!/bin/bash
STR="$(/sbin/ifconfig)"

echo "$STR" | ssmtp my.email@gmail.com


It is a very simple script and it works when i run it using sh emailIP.sh



When I run sudo systemctl start rc-local.service and then run sudo systemctl status rc-local.service



I get this output:



 ● rc-local.service - /etc/rc.local Compatibility
Loaded: loaded (/etc/systemd/system/rc-local.service; enabled; vendor preset: enabled)
Drop-In: /lib/systemd/system/rc-local.service.d
└─debian.conf
Active: active (exited) since Sat 2019-03-23 14:45:28 CDT; 15min ago
Process: 4391 ExecStart=/etc/rc.local start (code=exited, status=0/SUCCESS)

Mar 23 14:45:28 servanh-desktop systemd[1]: Starting /etc/rc.local Compatibility...
Mar 23 14:45:28 servanh-desktop rc.local[4391]: ssmtp: Cannot open smtp.gmail.com:587
Mar 23 14:45:28 servanh-desktop sSMTP[4497]: Unable to locate smtp.gmail.com
Mar 23 14:45:28 servanh-desktop sSMTP[4497]: Cannot open smtp.gmail.com:587
Mar 23 14:45:28 servanh-desktop systemd[1]: Started /etc/rc.local Compatibility.


So what I am not understanding is why it is giving me this Unable to locate smtp.gmail.com error when its in my /etc/ssmtp/ssmtp.conf and if that file was not configured correctly then my script would not run when I do sh emailIP.sh?



Edit: Me sad










share|improve this question
















I have ubuntu 18.04 and I recently added the rc.local script to /etc/ so I could run my emailing script to email myself my IP address from my jetson nano computer. I need it to email me because I cannot setup a static IP and the IP changes occasionally. The computer will be setup on a 1:16 RC race car so I have to ssh into it.



I used this tutorial to setup ssmtp on ubuntu: https://stackoverflow.com/questions/38391412/raspberry-pi-send-mail-from-command-line-using-gmail-smtp-server



I used this tutorial to attempt to run the script I show below on startup on ubuntu 18.04: https://www.linuxbabe.com/linux-server/how-to-enable-etcrc-local-with-systemd



This is my emailIP.sh :



#!/bin/bash
STR="$(/sbin/ifconfig)"

echo "$STR" | ssmtp my.email@gmail.com


It is a very simple script and it works when i run it using sh emailIP.sh



When I run sudo systemctl start rc-local.service and then run sudo systemctl status rc-local.service



I get this output:



 ● rc-local.service - /etc/rc.local Compatibility
Loaded: loaded (/etc/systemd/system/rc-local.service; enabled; vendor preset: enabled)
Drop-In: /lib/systemd/system/rc-local.service.d
└─debian.conf
Active: active (exited) since Sat 2019-03-23 14:45:28 CDT; 15min ago
Process: 4391 ExecStart=/etc/rc.local start (code=exited, status=0/SUCCESS)

Mar 23 14:45:28 servanh-desktop systemd[1]: Starting /etc/rc.local Compatibility...
Mar 23 14:45:28 servanh-desktop rc.local[4391]: ssmtp: Cannot open smtp.gmail.com:587
Mar 23 14:45:28 servanh-desktop sSMTP[4497]: Unable to locate smtp.gmail.com
Mar 23 14:45:28 servanh-desktop sSMTP[4497]: Cannot open smtp.gmail.com:587
Mar 23 14:45:28 servanh-desktop systemd[1]: Started /etc/rc.local Compatibility.


So what I am not understanding is why it is giving me this Unable to locate smtp.gmail.com error when its in my /etc/ssmtp/ssmtp.conf and if that file was not configured correctly then my script would not run when I do sh emailIP.sh?



Edit: Me sad







18.04 bash scripts startup ssmtp






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 23 at 20:47







Dayman

















asked Mar 23 at 20:27









DaymanDayman

62




62













  • Perhaps the required network services (name resolution in particular) are not ready at that time?

    – steeldriver
    Mar 23 at 21:12











  • Would that still be a problem if I test rc.local while my device is already booted? Does 'sudo systemctl start rc-local.service' recreate boot sequence?

    – Dayman
    Mar 23 at 21:24













  • Hmm... that's a good point - I must admit I read your question quickly and assumed the output was from the bootime journal. I don't know what happens when the rc-local service is started later.

    – steeldriver
    Mar 23 at 21:45











  • Don't worry I sometimes read over too fast too. Thank you for taking a look I really do appreciate it.

    – Dayman
    Mar 23 at 21:49











  • The same error message, "ssmtp: Cannot open..." was discussed in This question. You might check to see if any of the comments or answers apply to your situation.

    – John1024
    Mar 23 at 23:50



















  • Perhaps the required network services (name resolution in particular) are not ready at that time?

    – steeldriver
    Mar 23 at 21:12











  • Would that still be a problem if I test rc.local while my device is already booted? Does 'sudo systemctl start rc-local.service' recreate boot sequence?

    – Dayman
    Mar 23 at 21:24













  • Hmm... that's a good point - I must admit I read your question quickly and assumed the output was from the bootime journal. I don't know what happens when the rc-local service is started later.

    – steeldriver
    Mar 23 at 21:45











  • Don't worry I sometimes read over too fast too. Thank you for taking a look I really do appreciate it.

    – Dayman
    Mar 23 at 21:49











  • The same error message, "ssmtp: Cannot open..." was discussed in This question. You might check to see if any of the comments or answers apply to your situation.

    – John1024
    Mar 23 at 23:50

















Perhaps the required network services (name resolution in particular) are not ready at that time?

– steeldriver
Mar 23 at 21:12





Perhaps the required network services (name resolution in particular) are not ready at that time?

– steeldriver
Mar 23 at 21:12













Would that still be a problem if I test rc.local while my device is already booted? Does 'sudo systemctl start rc-local.service' recreate boot sequence?

– Dayman
Mar 23 at 21:24







Would that still be a problem if I test rc.local while my device is already booted? Does 'sudo systemctl start rc-local.service' recreate boot sequence?

– Dayman
Mar 23 at 21:24















Hmm... that's a good point - I must admit I read your question quickly and assumed the output was from the bootime journal. I don't know what happens when the rc-local service is started later.

– steeldriver
Mar 23 at 21:45





Hmm... that's a good point - I must admit I read your question quickly and assumed the output was from the bootime journal. I don't know what happens when the rc-local service is started later.

– steeldriver
Mar 23 at 21:45













Don't worry I sometimes read over too fast too. Thank you for taking a look I really do appreciate it.

– Dayman
Mar 23 at 21:49





Don't worry I sometimes read over too fast too. Thank you for taking a look I really do appreciate it.

– Dayman
Mar 23 at 21:49













The same error message, "ssmtp: Cannot open..." was discussed in This question. You might check to see if any of the comments or answers apply to your situation.

– John1024
Mar 23 at 23:50





The same error message, "ssmtp: Cannot open..." was discussed in This question. You might check to see if any of the comments or answers apply to your situation.

– John1024
Mar 23 at 23:50










0






active

oldest

votes












Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1128128%2fwhy-does-my-mailing-script-work-outside-of-rc-local-but-not-when-i-run-rc-local%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Ask Ubuntu!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1128128%2fwhy-does-my-mailing-script-work-outside-of-rc-local-but-not-when-i-run-rc-local%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

數位音樂下載

When can things happen in Etherscan, such as the picture below?

格利澤436b