• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 950
  • Last Modified:

Unix script command Find -exec | mailx

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
eshapley
Asked:
eshapley
  • 3
1 Solution
 
woolmilkporcCommented:
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
 
eshapleyAuthor Commented:
Thank you !!
0
 
woolmilkporcCommented:
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
 
woolmilkporcCommented:
Sorry, the last part should read "-c alone is not a valid flag for IBM's mailx"
0
 
TintinCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now