Send email from command line using gmail and ssmtp

This is a very good tool i use to email me of any notifications on my centos box. Plus i use it to send emails when i am working on command line.

If you havent already installed the EPEL i386 Repo, then do
# rpm -Uvh

# yum remove sendmail (optional)
# yum install ssmtp

Now, configure the ssmtp.conf file:
# vi /etc/ssmtp/ssmtp.conf
AuthPass=(your – password)

# service sendmail stop ( if not removed above)
# chkconfig sendmail off (if not removed above)
# mkdir /root/.backup
# mv /usr/sbin/sendmail /root/.backup/
# whereis ssmtp
ssmtp: /usr/sbin/ssmtp /etc/ssmtp /usr/share/man/man8/ssmtp.8.gz
# ln -s /usr/sbin/ssmtp /usr/sbin/sendmail
# echo “This is a test email” | mail -s “Test”
This will send an email to …..
You can use this on a script,cron and any log messages now to make the centos box email you the issues…. comment on any help needed.


run automatic backup on usb as soon as it’s plugged in

[root@saurap /]# cat /proc/scsi/usb-storage/*
Host scsi27: usb-storage
Vendor: Sony
Product: Storage Media
Serial Number: 2A07060549833
Protocol: Transparent SCSI
Transport: Bulk

[root@saurap saurap]# vi /etc/udev/rules.d/pendrive.rules
#BUS=”usb”, SYSFS{serial}=”2A07060549833″, SYMLINK=”Storage\ Media”, RUN+=”/home/saurap/”
SUBSYSTEMS==”usb”, ATTRS{serial}==”2A07060549833″, SYMLINK+=”Storage”, RUN+=”/home/saurap/”

Then create the script for backup as

mount /dev/sdb1 /media/PEN
sleep 3
rsync -zvr /home/saurap/Desktop/mine/ /media/PEN/backup