The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
capture shell output in cron entry steve72 UNIX for Dummies Questions & Answers 5 04-17-2008 08:00 AM
Help with script - run by cron richo king Shell Programming and Scripting 2 03-05-2008 04:36 PM
Duplicate output from "cron" messages loeng SUN Solaris 8 11-13-2005 08:25 PM
cron output = 0 bytes mbattreall SUN Solaris 8 06-28-2005 01:58 PM
Cron Script Q doublek321 Shell Programming and Scripting 2 07-06-2004 06:35 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-14-2004
Registered User
 

Join Date: Dec 2004
Posts: 2
Cron + Script = No Output?

I've got an *extremely* simple script I want to run every minute:

Code:
#!/bin/sh
ping -c 1 192.168.1.20 > ~/onlinestatus.txt
So, the script is called "status", it's executable, and in the correct path, etc. In a terminal window (I'm using Mac OS X), I can type status, and it will create onlinestatus.txt with the ping output in it. Everything seems to be working fine.

HOWEVER, when I put the command in my crontab as

* * * * * status

It doesn't work. Or, to be more precise, it creates an *empty* onlinestatus.txt file. I can use Cronnix (a GUI crontab editor) to force the command to run. When I do that, onlinestatus.txt *does* contain the ping output; it seems like it's only when cron runs it at the scheduled interval that the text file comes out empty.

I'm *thoroughly* confused. If it didn't work *at all*, I could deal with it, but this behavior doesn't seem to make any sense. Any suggestions?
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 12-14-2004
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,454
Maybe your ping writes to stderr rather than stdout. Try:
ping -c 1 192.168.1.20 > ~/onlinestatus.txt 2>&1
Reply With Quote
  #3 (permalink)  
Old 12-15-2004
Registered User
 

Join Date: Dec 2004
Posts: 2
Well, adding 2>&1 actually put some output in the file, except it's not what I'd hoped. I get some kind of "Resource not available" error written to the file now. What does that translate to?

Thanks!
Reply With Quote
  #4 (permalink)  
Old 12-21-2004
Kelam_Magnus's Avatar
Unix does a body good.
 

Join Date: Aug 2001
Location: DFW McKinney, TX,
Posts: 1,069
First way to test a script is to execute it on the command line...if that succeeds then you should be able to run it from cron...

sometimes you might need to add a line "set -x" to test and see where your error is.
__________________
My brain is your brain
Reply With Quote
  #5 (permalink)  
Old 12-21-2004
zazzybob's Avatar
Registered Geek
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
Quote:
Originally posted by jmf77
I get some kind of "Resource not available" error written to the file now. What does that translate to?
What's the exact output left in the file?

If it's something along the lines of "Destination unreachable", or something along those lines it's not a problem with your script.

Post the contents of the output file.

Cheers
ZB
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 06:37 AM.


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

Content Relevant URLs by vBSEO 3.2.0