The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 and shell scripting languages 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 09:39 PM
Unable to send mail - but no errors found :-( csaha Linux 6 02-03-2006 04:21 PM
java errors when calling from cron mntamago Shell Programming and Scripting 3 11-18-2002 09:50 AM
cron command not found sstevens UNIX for Dummies Questions & Answers 4 07-17-2002 11:28 PM
errors when running a cron job knarayan UNIX for Dummies Questions & Answers 2 01-23-2002 02:00 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-05-2007
goodmis goodmis is offline
Registered User
  
 

Join Date: Jan 2007
Posts: 24
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
  #2 (permalink)  
Old 02-05-2007
goodmis goodmis is offline
Registered User
  
 

Join Date: Jan 2007
Posts: 24
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
  #3 (permalink)  
Old 02-05-2007
goodmis goodmis is offline
Registered User
  
 

Join Date: Jan 2007
Posts: 24
Dev Null

> /dev/null 2>&1

I can suppress all errors but I might miss a legitimate error.
  #4 (permalink)  
Old 02-05-2007
funksen funksen is offline Forum Advisor  
Registered User
  
 

Join Date: Nov 2006
Location: Austria/Vienna
Posts: 430
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
  #5 (permalink)  
Old 02-05-2007
goodmis goodmis is offline
Registered User
  
 

Join Date: Jan 2007
Posts: 24
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
  #6 (permalink)  
Old 02-06-2007
funksen funksen is offline Forum Advisor  
Registered User
  
 

Join Date: Nov 2006
Location: Austria/Vienna
Posts: 430
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 ....
  #7 (permalink)  
Old 02-06-2007
aigles's Avatar
aigles aigles is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,414
Read how can i check if text file is closed ?


Jean-Pierre
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 04:54 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0