mailx
Download mailx
(openSUSE is the distribution of my server) and install it.
$ make PREFIX=/public/home/zhangxin/softwares/mailx SYSCONFDIR=/public/home/zhangxin/softwares/mailx/etc
$ make install UCBINSTALL=/usr/bin/install PREFIX=/public/home/zhangxin/softwares/mailx SYSCONFDIR=/public/home/zhangxin/softwares/mailx/etc
Get your authorization code and edit mailx/etc/nail.rc
set from="[email protected]"
set smtp=smtp.qq.com
set smtp-auth-user="[email protected]"
set smtp-auth-password="authorization_code"
set smtp-auth=login
Test:
$ echo "haha" | mailx -v -s "Test" [email protected]
Usage:
mailx -T FILE -u USER -h hops -r address -s SUBJECT -a FILE -q FILE -f FILE -A ACCOUNT -b USERS -c USERS -S OPTION users
inotifywait
Download inotifywait from here and install it.
#!/bin/bash
inotifywait -m /public/software/anaconda/requirements.txt --timefmt '%d/%m/%y %H:%M' --format '%T %w %f' -e modify -e move -e delete_self | while read date time action dir file; do
FILECHANGE=${dir}${file}
echo "At ${time} on ${date}, file $FILECHANGE was touched via '$action'" | mailx -s "requirements" -a /public/software/anaconda/requirements.txt [email protected]
done
Explanation:
-m|--monitor Keep listening for events forever. Without
this option, inotifywait will exit after one
event is received.
-e|--event <event1> [ -e|--event <event2> ... ]
Listen for specific event(s). If omitted, all events are
listened for.
Say something
Thank you
Your comment has been submitted and will be published once it has been approved.
Click here to see the pull request you generated.
OOPS!
Your comment has not been submitted. Please go back and try again. Thank You!
If this error persists, please open an issue by clicking here.