Send email from command line or at startup in SCALE

I would like to have SCALE send an email at startup (after booting). The reason is that SCALE rebooted randomly recently due to a memory error that cause a kernel panic. I don’t know if it was a one-off fluke or a more serious problem; so I would like to get notified whenever SCALE boots. Does anyone know how to do this?

If I can send an email from the command line, then I can do so at startup by adding an INIT script under System, Advanced. So I just need to know how to do so from the command line.

Incidentally, I have learned how to send an email from the SCALE CLI as discussed here: Mail |

However, this does not help because, at least as I understand it, the SCALE CLI is interactive only and cannot be scripted.

Maybe something like this?

echo "The server booted up at $(date)" | mail -s "TrueNAS Bootup Notice" someone@example.com

This assumes (and requires) that you have outgoing email server settings and authentication configured in TrueNAS.

3 Likes

Winnielinnie you’re a hero as usual. That worked.

I need to come up with a personal icon for the new forum, and this time I won’t use Linux Mint to step on your game like in the old forum.

1 Like

I think it was cool when we both had similar avatars. :grin: Feel free to use it again! No need to ask my permission. Never need to. :vulcan_salute:

I remember the massive protests that erupted. :open_mouth: People flooded the streets!

EDIT: Give my posts a like! I must surpass a certain someone in the leaderboard. :neutral_face:

2 Likes

I should have thought of this, but the OPNsense router that provides internet access to my house is virtualized as a VM on the SCALE server that’s the subject of this post. Since it takes a while for OPNsense to boot up after SCALE boots up, it’s necessary to pause the INIT script before sending the email in order to give OPNsense time to boot, or else the email doesn’t send. I chose a 600 second (10 minute) delay, which was overkill in my case.

In case anyone else is in this situation, here is the modified script that delays before sending the email: sleep 600 && echo “The server booted up at $(date)” | mail -s “TrueNAS Bootup Notice” someone@example.com

1 Like

On a few customers I have multiple TrueNAS servers, so I’ll use the following, to differentiate between them:

echo "$(hostname) booted up at $(date)" | mail -s "TrueNAS Bootup Notice" someone@example.com

2 Likes

I have a virtual pfsense too.

I use the wait_for_ssh script here:

To start a vm after my pfsense comes online.

Same thing could work well for you.

1 Like