Script runs in shell but not cron | Unix Linux Forums | AIX

  Go Back    


AIX AIX is IBM's industry-leading UNIX operating system that meets the demands of applications that businesses rely upon in today's marketplace.

Script runs in shell but not cron

AIX


Tags
cron script doesn't shell run, solved

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 12-31-2012
herot herot is offline
Registered User
 
Join Date: Nov 2008
Last Activity: 31 December 2012, 7:44 PM EST
Posts: 72
Thanks: 3
Thanked 0 Times in 0 Posts
[Solved] Script runs in shell but not cron

We run some menu driven software that has the ability to batch menu paths and generate reports quickly. Normally you run a batch like:

Code:
$ BATCH BATCHNAME

The batch program then prompts you for the date you want the report run for. I got some help from some folks on IRC to do the following:

Code:
BATCH BATCHNAME $(date +%y%d%m)

This allowed me to run the batch using the current date without having to enter the date at the prompt (it auto-fills the prompt in effect). It runs fine from the $ (ksh) and it runs fine from a script (sh something). However, when I try to run it with cron it errors out with invalid date. I have tried calling the script from cron AND running the straight BATCH command from cron (both methods listed above). Why wont cron let me feed the above date variable to my batch program?
Sponsored Links
    #2  
Old 12-31-2012
bakunin bakunin is offline Forum Staff  
Bughunter Extraordinaire
 
Join Date: May 2005
Last Activity: 2 September 2014, 8:39 AM EDT
Location: In the leftmost byte of /dev/kmem
Posts: 4,210
Thanks: 44
Thanked 801 Times in 632 Posts
You are probably falling for Cron Problem Number One.

I hope this helps.

bakunin
The Following User Says Thank You to bakunin For This Useful Post:
herot (12-31-2012)
Sponsored Links
    #3  
Old 12-31-2012
herot herot is offline
Registered User
 
Join Date: Nov 2008
Last Activity: 31 December 2012, 7:44 PM EST
Posts: 72
Thanks: 3
Thanked 0 Times in 0 Posts
checking the users in smit, i am seeing that cron user has the same home directory and all the same settings as MY username. and no, i did not make it that way.

SOLVED. that was the ticket bakunin. I had been messing around with env stuff in my script already with no luck. then i tried
Code:
TERM=ansi

and that got it.

Thanks!

Moderator's Comments:
edit by bakunin: thanks for the follow-up. Changed thread title accordingly.

Last edited by bakunin; 01-02-2013 at 07:01 AM..
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
[SOLVED] Only half my script runs vsekvsek UNIX for Dummies Questions & Answers 3 11-30-2012 03:33 PM
[Solved] Shell not running through cron Jcpratap Shell Programming and Scripting 6 11-27-2012 09:34 AM
Shell Script runs good manually but not through Cron tab naren.chowdhary Shell Programming and Scripting 1 05-14-2012 01:02 PM
CRON shell script only runs correctly on command line louieaw Shell Programming and Scripting 4 04-06-2011 04:21 AM
Script runs fine, but not in a cron sammyk Shell Programming and Scripting 4 01-24-2010 10:35 AM



All times are GMT -4. The time now is 05:22 PM.