Script runs in shell but not cron


 
Thread Tools Search this Thread
Operating Systems AIX Script runs in shell but not cron
# 1  
Old 12-31-2012
[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?
# 2  
Old 12-31-2012
You are probably falling for Cron Problem Number One.

I hope this helps.

bakunin
This User Gave Thanks to bakunin For This Post:
# 3  
Old 12-31-2012
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:
Mod Comment edit by bakunin: thanks for the follow-up. Changed thread title accordingly.

Last edited by bakunin; 01-02-2013 at 08:01 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script runs manually, but not from cron

Hi, I "borrowed" a script I found online, to start a SAP router application on a Solaris 11 (SPARC) server. The script runs fine when calling it manually, but when I schedule it to run from cron, it doesn't. I don't see any warning or failure messages anywhere, just nothing happens. ... (11 Replies)
Discussion started by: bredman
11 Replies

2. Shell Programming and Scripting

Script runs in command-line fine but times out in CRON?

Hi, I have a script that seems to run to completion when in the command-line, but when it is run using the cron, it seems to time out. They both start and run fine, but on the CRON it stops prematurely. The script hits an API every few seconds and grabs data. Does anyone have any idea on... (4 Replies)
Discussion started by: phpchick
4 Replies

3. Shell Programming and Scripting

Odd results when my script runs from cron..

Hi folks, So I wrote a script to run "top", "awk" out values fro the "top" and send the results to a data file. I then set it to run in cron every 15 minutes. Now I'm noticing that the script, and it's sub-commands are not always cleanly finishing and, in my investigations, I am also... (11 Replies)
Discussion started by: Marc G
11 Replies

4. Shell Programming and Scripting

Shell Script runs good manually but not through Cron tab

Hello Every one, I have a shell script which is running fine manually, but its giving me hard time when running tru cron job. :wall:. Am using #!/usr/bin/ksh >echo $SHELL /usr/bin/ksh Cron Job is as below, it execues but dosent do what i want it to do. 47 15 * * *... (1 Reply)
Discussion started by: naren.chowdhary
1 Replies

5. Shell Programming and Scripting

Shell script that runs a random shell script

Hi, im trying to make a shell script that basically runs a random shell script form a list of shell scripts i specify. Im not very good at writing shell scripts, and am new to linux. Thanks in advance :) (15 Replies)
Discussion started by: kylecn
15 Replies

6. Shell Programming and Scripting

CRON shell script only runs correctly on command line

Hi, I'm new to these forums, and I'm hoping that someone can solve this problem... To make things short: I have DD-wrt set up on a router. I'm trying to run a script in CRON that fetches the daily password from my database using SSH. CRON is set like so(in web interface): * * * *... (4 Replies)
Discussion started by: louieaw
4 Replies

7. Shell Programming and Scripting

Script runs fine, but not in a cron

Okay, I have the following script that runs fine from a command line as well as an executable .sh file. It just moves any file/folder with movie* in the name to a folder called _Movies. The issue I'm running into is when it's call from a cron. find /mnt/HD_a2/BT/complete -iname "movie.*" -exec... (4 Replies)
Discussion started by: sammyk
4 Replies

8. Shell Programming and Scripting

Shell script which runs sql script

Hi all, I need a shell script which runs a sql script but I couldn't find how to finish it. This is the code that I have: #! /usr/bin/ksh export SHELL=/bin/ksh export ORACLE_SID=database export ORACLE_HOME=/opt/oracle/product/9.2.0.8 sqlplus user <<EOF @/path/path/path/scriptname.sql... (3 Replies)
Discussion started by: Geller
3 Replies

9. Solaris

Sunsolaris shell script runs only as super user

Hi Friends, I am new to Sun solaris unix.I am facing problem while runing my kornshell script just as an ordinary user.The script works fine while i am working as a super user.the script just uses awk to check the first charcter of a file and then copies the file to another folder. Do i... (4 Replies)
Discussion started by: gjithin
4 Replies

10. Shell Programming and Scripting

Shell Script: want to insert values in database when update script runs

Hi , I am new to linux and also also to shell scripting. I have one shell script which unpacks .tgz file and install software on machine. When this script runs I want to insert id,filename,description(which will be in readme file),log(which will be in log file) and name of unpacked folder... (1 Reply)
Discussion started by: ring
1 Replies
Login or Register to Ask a Question