-
Renaming .bad files
This is a (bash) script that renames my import bad file(s) if they exist with a date stamp.
for file in /import/load/bad/*.bad
do
mv $file $file-`date "+%y%m%d%n"`
done
If there are no bad files, I get this error message:
"No such file or directory"
It triggers cron to send me an email that is not necessary. I don't want to know that there are no bad files.
I've tried a couple things that haven't worked:
Encase in if
----------------
if [ -e /import/load/bad/*.bad ];
then
do ... done
fi
RESULT: line 1: [: /import/load/bad/verb1.bad: binary operator expected
NOTE: I'm guessing I can't test with a wildcard.
Get last file
-------------
CHECK=`ls -rt /import/load/bad/*.bad|tail -1`
echo $CHECK
RESULT: ls: /import/load/bad/*.bad: No such file or directory
-
How does that script trigger a cronjob?
Can you post the cronjob?
I remember when this place was cool.
-
man find
find /import/load/bad/ -name \*.bad -type f
Jeff Hunter
-
Originally posted by Mr.Hanky
How does that script trigger a cronjob?
Can you post the cronjob?
Look Windoz boy, when the job you are running sends output to stderr cron sends you the output of stderr in an email.
Jeff Hunter
-
Originally posted by marist89
Look Windoz boy, when the job you are running sends output to stderr cron sends you the output of stderr in an email.
HUH?
I NEVER got an email from ANY Unix job I have run.
Educate us all oh "Geniused" one.
http://www.ucs.ed.ac.uk/usd/scisup/f...rection-1.html
Says the default is the terminal.
Last edited by Mr.Hanky; 06-15-2005 at 03:50 PM.
I remember when this place was cool.
-
"find" is so sweet...
/usr/bin/find /import/load/bad/ -name \*.bad -type f -exec mv {} {}-`date "+%y%m%d%n"` \;
When there are no files, it doesn't return the error.
Nice .. Thanks guys!
-
Errr, that link isn't talking about cron.
From http://216.147.18.102/unixfaq/cron.shtml:
"Any output your cron job produces, both stdout and stderr, will be sent to you by Unix email
Last edited by hacketta1; 06-16-2005 at 07:23 AM.
-
Originally posted by Mr.Hanky
HUH?
I NEVER got an email from ANY Unix job I have run.
Hey genious, log into Unix and type mail, then press return!
-
This could also have worked
for file in `ls -l /import/load/bad/*.bad 2>/dev/null`
do
echo $file
done
There are three kinds of lies: Lies, damned lies, and benchmarks...
Unix is user friendly. It's just very particular about who it's friends are.
Oracle DBA
-
Originally posted by Mr.Hanky
I NEVER got an email from ANY Unix job I have run.
Perhaps you never ran a cron job, eh?
From a cron my point-and-click friend, the default is mail.
Jeff Hunter
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|