How do I prevent cron from returning errors on a file not found?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How do I prevent cron from returning errors on a file not found?
# 1  
Old 02-05-2007
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  
Old 02-05-2007
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  
Old 02-05-2007
Dev Null

> /dev/null 2>&1

I can suppress all errors but I might miss a legitimate error.
# 4  
Old 02-05-2007
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  
Old 02-05-2007
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  
Old 02-06-2007
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  
Old 02-06-2007
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Expect script returning string following a found expect.

I'm fairly new to scripting so this might not be possible. I am using Expect with Cisco switches and need to capture the string after finding the expect request. For example, when I issue "show version" on a Nexus switch, I'm looking to capture the current firmware version: #show version ... (0 Replies)
Discussion started by: IBGaryA
0 Replies

2. Shell Programming and Scripting

Ssh from a ksh returning not found message

Script name is test.ksh I know that that the ssh command is working properly, this can be verified by the value returned in respond variable. It is unique to the remote server _____________________________________________________ respond=$(ssh $remoteHost find... (3 Replies)
Discussion started by: Adagio
3 Replies

3. Shell Programming and Scripting

Command not found errors when running csh script

I am trying to find the number of files whose name starts with uni. Below is the code but it is giving error. :confused: #!/bin/csh FILES_NAME ='files_list'; FILE_NAME_PATTERN = 'uni*'; NO_OF_FILES; ls -l $FILE_NAME_PATTERN > $FILES_NAME ; NO_OF_FILES = `wc -l $FILES_NAME`; echo... (3 Replies)
Discussion started by: hiten.r.chauhan
3 Replies

4. Shell Programming and Scripting

Cron job to prevent simultaneous script

I'm using a shared server on Hostgator (Linux CentOS). I'm trying to set a cron job using the Control Panel that will check if its already running before starting a new one. I've tried the following... * * * * * && but I get this error emailed to me... /bin/sh: line 0: Any... (5 Replies)
Discussion started by: tech9821
5 Replies

5. UNIX for Dummies Questions & Answers

Loop on array variable returning error: 0 not found

I'm guessing i have a syntax error. I'm not sure it get's past the the while condition. I get an error 0 not found. Simple loop not sure what I'm doing wrong. #!/usr/bin/ksh set -A MtPtArray /u03 /u06 tUbound=${#MtPtArray } echo $tUbound i=0 while ($i -lt $tUbound) do print... (4 Replies)
Discussion started by: KME
4 Replies

6. UNIX for Advanced & Expert Users

How to prevent grep command from throwing a system trap if No match is found.

Hi How to prevent grep command from throwing a system trap(or returning error status) if No match is found in the specified file(s) ? Consider this simple shell script: #!/usr/bin/ksh trap 'STATUS=$?;set +x;echo;echo error $STATUS at line nb $LINENO executing :\ `sed -n... (2 Replies)
Discussion started by: cool.aquarian
2 Replies

7. Shell Programming and Scripting

prevent errors/warnings from being written to log file

i have this script which works fine but shows errors when it runs..these are more like warnings and the script runs fine.. i am on a sun machine.. i know it writes all the error messages to a master log file.. is there any way i can turn off these warnings/error messages and prevent them from being... (2 Replies)
Discussion started by: npatwardhan
2 Replies

8. Linux

Unable to send mail - but no errors found :-(

Hi Guys I am using this version of Linux box (as shown below). I am unable to send email from the box. But I am not getting any errors while sending email. :mad: Any idea what could be the reason? What entry should I check? :confused: $ uname -a Linux machine-name 2.4.21-144-smp4G #1... (6 Replies)
Discussion started by: csaha
6 Replies

9. Shell Programming and Scripting

java errors when calling from cron

I am more or less new to using cron, and I am trying to automate a log cleaning system I have made. The system basically cleans through WWW logs that are mounted on an NFS and creates text files for entry into a local PostgreSQL DB. For the past year I have been running the various scripts and... (3 Replies)
Discussion started by: mntamago
3 Replies

10. UNIX for Dummies Questions & Answers

errors when running a cron job

I am running some shell scripts through a foll cron job, the script works fine and there are no errors in the log file but I receive the following error in mail for the jobs: stty: no such device or address What does the above error indicate, here is the cron job: 0 22 * * 0... (2 Replies)
Discussion started by: knarayan
2 Replies
Login or Register to Ask a Question