Simple How To Guide: Setting Up Daily Email Notifications

Questions and mods regarding system management may go here
Forum rules
Please note the disclaimer before modifying your Synology Product.
mszymcza
Trainee
Trainee
Posts: 16
Joined: Sat May 21, 2011 5:30 pm

Simple How To Guide: Setting Up Daily Email Notifications

Postby mszymcza » Wed May 25, 2011 3:11 am

Here is a simple "How To Guide" for Setting Up Daily Email Notifications

A. Enable ssh and login as root to a command line shell
http://forum.synology.com/wiki/index.ph ... _Interface
1. Control Panel > Terminal > Terminal Service Option
2. Place a check in the "Enable SSH Service" checkbox
3. Click [OK] to save
4. Use putty to login as root over SSH port 22
5. Accept any certificates

C. Install ipkg (optional if you already have ipkg installed)
http://forum.synology.com/wiki/index.ph ... ,_ipkg_etc
1. cd /volume1/@tmp
2. wget http://{your appropriate URL for your hardware - see above link}
3. sh ./{full file name downloaded by wget}
4. reboot
5. ipkg update
6. ipkg upgrade

D. Install nail to enable sending emails from the command line
http://forum.synology.com/wiki/index.ph ... g_packages
1. ipkg install nail
2. vi /opt/etc/nail.rc
set smtp=smtp://yourmailprovidor (or) set smtp=smtp://xxx.xxx.xxx.xxx
set from="synology@yourdomain.com"
set smtp-auth=login
set smtp-auth-synology
set smtp-auth-password=email-user-password


E. Create a shell script to send out logs
1. cd /volume1/homes/admin
2. vi send-var-log-messages.sh
more /var/log/messages | /opt/bin/nail -s /var/log/messages synology
3. chmod 755 send-var-log-messages.sh

F. Setup Cron to run your job
1. cd /etc
2. vi crontab
NOTE: be sure to use [Tab] instead of your [space bar] for the column breaks. The sample below is using spaces and will not survive a reboot.

0 0 * * * root /volume1/homes/admin/send-var-log-messages.sh
3. /usr/syno/etc/rc.d/S04crond.sh stop
4. /usr/syno/etc/rc.d/S04crond.sh start

That's it! You are now setup to receive a daily email from your Synology NAS that has the messages log.

You can test the script ahead of the cron job at anytime if you wish to make sure your configuration is correct.
1. cd /volume1/homes/admin
2. ./send-var-log-messages.sh
Last edited by mszymcza on Fri Jun 03, 2011 3:20 pm, edited 2 times in total.
Netgear N600 WNDR3700 --- FW V1.0.7.98NA
Synology DS211j --- FW DSM 3.1-1613
Qty(2) 3TB WD30EZRS-00J99B0 --- FW 80.00A80
mszymcza
Trainee
Trainee
Posts: 16
Joined: Sat May 21, 2011 5:30 pm

Re: Simple How To Guide: Setting Up Daily Email Notification

Postby mszymcza » Fri Jun 03, 2011 3:18 pm

BTW, if you notice that your /etc/crontab is empty after reboot, you likely have used [space] instead of [Tab] between your columns. Go back in and vi your /etc/crontab file. Remove spaces and replace them with tabs. There is some sort of file validation during reboot that will nuke entries that don't conform exactly to what it expect for delineation.
Netgear N600 WNDR3700 --- FW V1.0.7.98NA
Synology DS211j --- FW DSM 3.1-1613
Qty(2) 3TB WD30EZRS-00J99B0 --- FW 80.00A80
Thasaidon
Trainee
Trainee
Posts: 18
Joined: Sat Sep 17, 2011 9:41 am

Re: Simple How To Guide: Setting Up Daily Email Notification

Postby Thasaidon » Fri Apr 20, 2012 8:13 am

Thanx for this great howto!
Just one question though...
Can I install nail when I already have Mailstation Plus/Roundcube running?

Thanx.

Return to “System Managment Mods”

Who is online

Users browsing this forum: No registered users and 2 guests