I want to make a script which reads a files after every one hour and grep a pariticular word on it and if it finds it than email me on my email address. Please tell me how i start and if there is some example
available then please tell me the link.
One thing more that for the emailing purpose, do i have to configure mail server or mail client on my machine..
#/bin/ksh
# this is myscript.sh
/usr/bin/grep -q 'particular word' /path/to/somefile
if [ $? -eq 0 ]
echo "particular word found in /path/to/somefile " | /usr/bin/mailx -s 'found it' \
me@mymailaccount.com
fi
Make an entry in crontab to run 10 minutes after the hour every hour
The workaround is to use a correct email address to send from. Your local mailx may have some option to control that, or (better) you should configure the system defaults so they actually make sense. If the box is not set up to receive mail then you probably want to configure it to use an address somewhere else (ideally, one which you own and which you read regularly).