i have an ubuntu 12.04. i install bsd-mailx in my ubuntu and have internet on my server. I set the alarm to send me an email, when who login to server with root user.
configurtion that send email notification to me is as follows. i add this cod in .bashrc file in root directory.
I use a script for this problem but acctually there is a application in server which automatically creates one directory and one file and after some hours it delets that file and folder and recreates them again.
What do i do, if i want to ignore ‘licence.php’ and ‘update’ directory in my script so the script doesn’t email their names (the file and folder name)
#!/bin/bash
inotifywait -mqr -e create,moved_to /usr/share/nginx/html/ | while read path action file; do
if [ "$file" != "licence.php" ] && [ "$file" != "update" ]; then
echo "The file '$file' appeared in directory '$path' via '$action'" | mailx -s "File ${NEWFILE} has been created" "mail@xxxxx.com"
fi
done
Acctually my script will email me file and folders which are made but it doesn’t ignore licence.php and update folder , ignore part in my script doesn’t work and even with creation of these 2 file and folder , script will continue its work and email me their names too.
How can i solve this problem?