The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to prevent an application from closing a file jasahl AIX 4 01-06-2008 05:39 PM
Unable to send mail - but no errors found :-( csaha Linux 6 02-03-2006 12:21 PM
java errors when calling from cron mntamago Shell Programming and Scripting 3 11-18-2002 05:50 AM
cron command not found sstevens UNIX for Dummies Questions & Answers 4 07-17-2002 08:28 PM
errors when running a cron job knarayan UNIX for Dummies Questions & Answers 2 01-22-2002 10:00 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-05-2007
Registered User
 

Join Date: Jan 2007
Posts: 24
Stumble this Post!
How do I prevent cron from returning errors on a file not found?

find: /home/Upload/*: No such file or directory


I am getting a find error when I run

for FILE in `find /home/Upload/* -prune -type f -newer TIMEFILE`
do

I need to run this job every 10 minutes to upload any new files that were added. Is there an easy way to prevent this?

Thanks
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 02-05-2007
Registered User
 

Join Date: Jan 2007
Posts: 24
Stumble this Post!
How can I verify if the file is open?

I am now running into the issue of a how can I verify that a file has finished downloading via ftp before I run an awk script against it?

How does awk handle this?

Thanks
Reply With Quote
  #3 (permalink)  
Old 02-05-2007
Registered User
 

Join Date: Jan 2007
Posts: 24
Stumble this Post!
Dev Null

> /dev/null 2>&1

I can suppress all errors but I might miss a legitimate error.
Reply With Quote
  #4 (permalink)  
Old 02-05-2007
Registered User
 

Join Date: Nov 2006
Location: Austria/Vienna
Posts: 204
Stumble this Post!
2> /tmp/file
var=$(wc -l /tmp/file)
if [ $var -gt 0 ]; then cat /tmp/file | mail -s "copy job error" your@e.mail; rm /tmp/file; fi

or generate an error log with timestamps
Reply With Quote
  #5 (permalink)  
Old 02-05-2007
Registered User
 

Join Date: Jan 2007
Posts: 24
Stumble this Post!
Thanks funsen,

I am confused as to how it fits together.

I can see running the cron job and writing standard error to a temp file on the cron job.

2> /tmp/file

What I don't understand when not to fire the awk script if there is an error.


var=$(wc -l /tmp/file)
if [ $var -gt 0 ] then cat /tmp/file | mail -s "copy job error" your@e.mail; rm
/tmp/file; fi


Thanks again for replying
Reply With Quote
  #6 (permalink)  
Old 02-06-2007
Registered User
 

Join Date: Nov 2006
Location: Austria/Vienna
Posts: 204
Stumble this Post!
if /tmp/file is not empty, which means an error occured, you get a mail, if not you get nothing - this can cause problems, because you don't know if the script didn't run at all

the wc -l is not needed, just wc works too, or you can just check if the file exists with "if [ -f /tmp/file ]; then ....
Reply With Quote
  #7 (permalink)  
Old 02-06-2007
aigles's Avatar
Registered User
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,211
Stumble this Post!
Read how can i check if text file is closed ?


Jean-Pierre
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 11:26 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0