System reboot triggers email?

Is it possible to have the system send out an email if a reboot occurs?

Under what circumstances is your system presumably unexpectedly rebooting?

You would need to identify what caused the reboot, an orderly software or even a NMI one would typically log to /var/log/sysylog something , a hardware failure not so much.

but get a ‘heads up’ by adding to your root cronjobs where your MAILTO is proper

@reboot echo “I rebooted”

1 Like

I’m thinking it could be anything from a local user rebooting it or a power issue. I have a mounted drive attached to the system for recordings and the last time the system rebooted the mounted drive unmounted and call recordings were lost. Samba also stopped running upon reboot so even after I remounted the drive it took me a minute to realize they couldn’t see it on their windows computers until I started samba again. As I type this I’m wondering if the real answer is to have the system mount the drive and start smb and nmb upon reboot.

If this indeed is the better answer would I add the mount and smb/nmb commands to

/etc/rc.d/rc.local?

Local users should not be allowed to reboot.

Explore your /var/log/syslog (might be only /var/log/messages in some setups) , It is easy to discriminate between orderly and perfunctory logging at the time of reboot.

Systemd is the system to use to orderly start systems as your boot, each service can set dependencies so maybe have your PBX directly depend on your CIFS service

1 Like

If you have the systemd rclocal legacy service working, and that would depend on how you installed your system, , but that’s a kinda not 21st century way

I had used the rc.local file when I was working with onsite SIP utilizing a single NIC. I only use the distro and most are V15 but perhaps the single NIC was a V13/14. Where can I find this systemd file?

Sorry, don’t know how the ‘distro’ handles legacy System V stuff

After googling, I can read this link.

Would these commands ensure that smb and nmb start upon a system reboot?

systemctl enable smb.service
systemctl enable nmb.service

that is how systemd knows to start a service on boot, the order of starting is how each service is written to be conditional on others being startwd (or stopped)4

How can I turn the mount command into a systemctl command that starts upon reboot? Currently, I run a command similar to this to mount the external HD:

mount /dev/sdc1 /mnt

I would put that in fstab if it not always plugged in , I would use a udev rule

Thank you for your help. I’ve not utilized the fstab before but will investigate.

when it is mounted , by whatever means, then

grep "^/dev/sdc1 /etc/mtab" >> /etc/fstab

would make the mount survive a reboot

1 Like

Just want to verify before I potentially make a big mistake as I imagine messing up the /etc/fstab file would be. I ran the grep command you provided and obtained

/dev/sdc1 /mnt fuseblk rw,relatime,user_id=0,group_id=0,allow_other,blksize=4096 0 0

I then accessed /etc/fstab and found the following:

#
# /etc/fstab
# Created by anaconda on Wed Jun  9 15:34:49 2021
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/SangomaVG-root /                       xfs     defaults        0 0
UUID=00bff869-c8f7-4727-954e-fbdabb96452c /boot                   ext4    defaults        1 2
UUID=F98C-793B          /boot/efi               vfat    umask=0077,shortname=winnt 0 0
/dev/mapper/SangomaVG-swaplv1 swap                    swap    defaults        0 0

should I just add this as a new line? the current formatting of the file struck me as odd

It will mount it exactly as you have before, mtab is “mount table” fstab is “File System Table” they speak the same language. you probably don’t need fuseblk or allow_other because fstab runs as root (user_id=0,group_id=0) but they won’t be harmful.

If anything ‘strikes you as odd’ yet you ‘have never utilized it’ then you should probably get your recipe from the google gods

1 Like

Greatly appreciate your help! thank you

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.