Solved

Unix script command Find -exec | mailx

Posted on 2010-08-31
5
879 Views
Last Modified: 2013-11-17
I want to send an email message to a user or distribution list (already created) if the file is older than sixty minutes.  Here is the command I am using.  I get an error "expression term lacks a required parameter.  I would like to get this command working, but will welcome other suggestions for tackling the same requirement.

find /fdmdev/proedi/temp -name 'PROEDI*.CHK' -amin +60 -exec echo "Found" {} | mailx -s "Error" -c shapley ";"
0
Comment
Question by:eshapley
  • 3
5 Comments
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 500 total points
ID: 33570131
Hi,

the error message is due to the missing semicolon following the "exec" construct. The statements following the pip" are not part of exec!
So it should be like this:

find /fdmdev/proedi/temp -name 'PROEDI*.CHK' -amin +60 -exec echo "Found" {} ";" | mailx -s "Error" -c shapley

wmp

0
 

Author Closing Comment

by:eshapley
ID: 33570224
Thank you !!
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 33570227
Just saw it - could it be that your mailx statement is missing a recipient? And if it's really AIX - "-c" is not a valid flag for IBM's mailx!
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 33570267
Sorry, the last part should read "-c alone is not a valid flag for IBM's mailx"
0
 
LVL 48

Expert Comment

by:Tintin
ID: 33575732
Note that amin +60 (or atime) won't necessarily tell you if a file is older than 60 minutes, because if you view the file, the atime will be reset.

Better to use mmin
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

As the title indicates, I have done this before. It chills me everytime I update the OS on my phone, (http://www.experts-exchange.com/articles/18084/Upgrading-to-Android-5-0-Lollipop.html) because one time I did this and I essentially had a bricked …
Sometimes a user will call me frantically, explaining that something has gone wrong and they have tried everything (read - they have messed it up more and now need someone to clean up) and it still does no good, can I help them?!  Usually the standa…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now