Solved

Unix script command Find -exec | mailx

Posted on 2010-08-31
5
893 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses

738 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