Works Manually - not in CRON


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Works Manually - not in CRON
# 1  
Old 03-03-2006
Works Manually - not in CRON

I've got a ksh script that works like a charm when I run it manually. When I set it up in a cron, I keep getting this error in my log:

syntax error at line 90: `$' unexpected

Here's my snippet of code starting at line 90:

while [[ ! -e $DATA_DIR/tuscprof.dat && $(date '+%H:%M') < 10:00 ]]
do
sleep 900
done

What's the problem?
# 2  
Old 03-03-2006
In the first line of your script put:

Code:
#! /usr/bin/ksh

# 3  
Old 03-03-2006
It already has this line at the top, after the path:

. /usr/local/bin/TEST.env

PATH=/usr/lbin:/usr/bin:/etc:/usr/sbin:/usr/ucb:/sbin:/bin:/usr/local/bin:$ORACLE_HOME:$ORACLE_HOME/bin:/apps:.; export PATH

SHELL=/bin/ksh
export SHELL

Mind you, this was not my original script so I don't know much about certain portions of it, including this one
# 4  
Old 03-03-2006
Quote:
Originally Posted by dstinsman
It already has this line at the top, after the path:

. /usr/local/bin/TEST.env

PATH=/usr/lbin:/usr/bin:/etc:/usr/sbin:/usr/ucb:/sbin:/bin:/usr/local/bin:$ORACLE_HOME:$ORACLE_HOME/bin:/apps:.; export PATH

SHELL=/bin/ksh
export SHELL

Mind you, this was not my original script so I don't know much about certain portions of it, including this one
That's not going to help you. You need to put the line I suggested at the First line in the script.
# 5  
Old 03-03-2006
Quote:
Originally Posted by dstinsman
It already has this line at the top, after the path:

. /usr/local/bin/TEST.env

PATH=/usr/lbin:/usr/bin:/etc:/usr/sbin:/usr/ucb:/sbin:/bin:/usr/local/bin:$ORACLE_HOME:$ORACLE_HOME/bin:/apps:.; export PATH

SHELL=/bin/ksh
export SHELL

Mind you, this was not my original script so I don't know much about certain portions of it, including this one
That's not what dangral is refering to.

The very first line of the script needs to be #! /usr/bin/ksh. This forces the execution shell to become a Korn shell and not SH as is your case. The specific line cannot come after anything and it must be line 1.
# 6  
Old 03-06-2006
My cron job worked all weekend. Thanks guys!
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

"Mv" command does not work in loop, but works manually

Hi there, this may be a beginner's error, but I've been unable to find a solution on my own and by googling, and now I am really stuck on it. I am simply trying to move directories called for example CAT_Run01.ica to a directory with the corresponding number, Run01, in the same directory. For... (2 Replies)
Discussion started by: andrevol
2 Replies

2. Shell Programming and Scripting

Shell Script has different ouput via cron vs when run Manually

Hello Lads, I deployed a script on my mac to start and stop EC2 instances on AWS console. The script when started manually on the terminal does the expected stop and start. Problem is when i try to schedule it on a cron, it fails to recognize the AWS Keys which i set up as ENV variable by... (2 Replies)
Discussion started by: Irishboy24
2 Replies

3. 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

4. UNIX for Dummies Questions & Answers

Execution problem with Cron: Script works manually but not w/Cron. Why?

Hello gurus, I am making what I think is a simple db2 call from within a shell script but I am having difficulty producing the desired report when I run the script shown below from a shell script in cron. For example, my script and the crontab file setup is shown below: #!/bin/ksh db2... (3 Replies)
Discussion started by: okonita
3 Replies

5. Shell Programming and Scripting

Calling bash script works when called manually but not via Cron?

Hi, I've got a Bash backup script I'm trying to run on a directory via a cron job nightly. If I ssh in and run the script manually it works flawlessly. If I set up the cron to run evertything is totally messed up I don't even know where to begin. Basically the path structure is ... (6 Replies)
Discussion started by: wyclef
6 Replies

6. Shell Programming and Scripting

Why my git command has no output in crontab but works well run this script manually?

cat /home/lyang001/update.sh #!/bin/sh #shopt -s expand_aliases HOME_DIR=/home/lyang001/updates UPDATE_MAIL=${HOME_DIR}/updates.mail rm $UPDATE_MAIL -rf cd $HOME_DIR/wr-kernel git log --no-merges --since="20 day ago" --name-status --pretty=format:"%an %h %s %cd" origin/WRLINUX_5_0_1_HEAD >>... (2 Replies)
Discussion started by: yanglei_fage
2 Replies

7. Solaris

prtdiag command works only from commandline manually

When i run the command sudo /usr/sbin/prtdiag manually on a solaris 10 box, it works as expected. But the same command from my java code gives me the following error. picl_initialize failed: Daemon not responding. I am unable to figure out why is not running from my code.:wall: (3 Replies)
Discussion started by: randeepsp
3 Replies

8. Shell Programming and Scripting

Getting issue while running it from cron while manually working fine

Hello, I am working one one script where I am using the below code which is using to connect with MKS client when I run my script manually it works effiecently i.e. it connects with MKS client but when I run it from CRON it doesn't connect. 1)Can some one tell when it is running from cron... (1 Reply)
Discussion started by: anuragpgtgerman
1 Replies

9. Shell Programming and Scripting

Script behaves different when run from cron vs. manually

Hey all, Just wanted to get some input on a script I am using to import files into a MySQL database. The process is pretty simple: my main server exports these files and FTPs them. I have a script that FTPs them to the machine running that runs this script. The FTP script runs without issue... (2 Replies)
Discussion started by: billtwild
2 Replies

10. Shell Programming and Scripting

Can run script Manually, but not through Cron?

Hi all, I have a main script (called OracleCleanup) that runs some sql queries. that runs off a wrapper script which contains the sources for the login information and and JOB_HOME (the script is below). When I schedule this job in the cron the log says that it cannot open my list file, which... (4 Replies)
Discussion started by: MadHatter
4 Replies
Login or Register to Ask a Question