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 and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Script through cron and command line rahulrathod UNIX for Dummies Questions & Answers 3 02-22-2008 07:10 AM
works step by step on command line but not in script whamchaxed Shell Programming and Scripting 2 12-06-2007 07:47 AM
script works on command line, not in cron job JackTheTripper UNIX for Dummies Questions & Answers 7 06-27-2007 02:51 AM
Script works fine until I | more Skovian Shell Programming and Scripting 2 01-11-2006 11:17 AM
Adding command line env in cron env abhijeetkul Shell Programming and Scripting 1 12-13-2005 09:42 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-24-2008
cdunavent cdunavent is offline
Registered User
  
 

Join Date: Sep 2001
Location: D.C.
Posts: 59
Cron job fails, but works fine from command line

I have a very basic script that essentially sends a log file, via FTP, to a backup server. My cron entry to run this every night is:

55 23 * * * /usr/bin/archive_logs

The script runs perfectly when executed manually, and actually worked via cron for about three weeks. However, it mysteriously stopped working. I removed the entry from cron, re-added it. I even changed the time in the cron entry and tried it again. It still won't run from cron, but, again, works like a champ when I run it manually.

Below is the script:
====================================================
#!/bin/sh
DAY=`date +%m%d%y`

#Copy log to /tmp and add timestamp
cp /archive/logs/sys/alarm.log /tmp/alarm.log.$DAY

#Send file to webservers
cd /tmp
ftp -n 123.45.678.90 << !
user xxxxxxxx yyyyyyyy!
cd Developers/VMSMSP/Archive/MSP/MSPWASH
put alarm.log.$DAY
!

#Cleanup
cd /tmp
rm alarm.log.$DAY
=======================================================

Any ideas?
  #2 (permalink)  
Old 09-24-2008
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2007
Location: Germany
Posts: 2,313
Redirect it's output to a file to see what's happening, ie.:


Code:
55 23 * * * /usr/bin/archive_logs > /tmp/archive_los.tmp123 2>&1

  #3 (permalink)  
Old 09-24-2008
cdunavent cdunavent is offline
Registered User
  
 

Join Date: Sep 2001
Location: D.C.
Posts: 59
I tried that, but when I take a look at archive_los.tmp123, it is empty.
  #4 (permalink)  
Old 09-24-2008
Guyverix Guyverix is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 4
Any chance that it is due to not having a full path? As I recall cron does not normally set up the entire environment including path data.
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 08:19 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