0

I have KSH script.

If I run it manually using ./scriptname.ksh then it would work fine.

but if I set up a crontab job, I get error that AQL not found. (AQL is like SQL but not different).

Here is my script code.

#!/usr/bin/ksh

AQL << EOF
select count(*) from <tableT>;
exit

Here is crontab -e

12 13 * * * /usr/users/somedir/dir3/dir4/scriptname.ksh > /usr/users/somedir/dir3/dir4/testz.txt 2>&1

Here is what crontab runs and outputs to testz.txt

/usr/users/somedir/dir3/dir4/scriptname.ksh: line 9: AQL: not found
user206168
  • 1,015
  • 5
  • 20
  • 40

1 Answers1

3

AQL is probably not in the PATH for the environment the script executes in. Try using the fully qualified path to AQL (e.g. /full/path/to/AQL). In general, for this reason as well as for security, it's a good practice to specify fully qualified paths in scripts.

Ben Whaley
  • 32,811
  • 7
  • 87
  • 85
  • but I just realized the problem. I login to server as somedir user and then only I can run AQL. I cannot run AQL as any other user. so when crontab tries to run AQL it won't recognize it. I tried this manually by logging in as root user. can you plz suggest a solution. – user206168 Mar 12 '14 at 18:39
  • 1
    Put the cron job in the somedir user's crontab. Log in as root, use `crontab -e -u somdeir`, add the cron job and save it. And also give the fully qualified path as suggested in my answer. – Ben Whaley Mar 12 '14 at 18:41
  • Thanks, for the suggestion but I can't find the path to AQL. :( I am super new to this. – user206168 Mar 12 '14 at 18:46
  • 1
    Try `find / -name AQL` – Ben Whaley Mar 12 '14 at 19:01
  • 1
    To find a program in ksh, do `whence -a AQL` – glenn jackman Mar 12 '14 at 19:10
  • I was able to find the path, and it was able to start AQL but it is not working correctly. (I changed query to `select count(*) from tableT;` I get this error `unable to translate the acronym Abort message from process 11229, program "AQL": COMMON y1_ftok error: Inappropriate ioctl for device` – user206168 Mar 12 '14 at 19:54
  • btw it still work correctly if I manually run the script by using `./scriptname.ksh` – user206168 Mar 12 '14 at 19:57
  • 1
    I was able to fix it by adding `su - somedir << EOF` before AQL command. Thanks all – user206168 Mar 14 '14 at 16:11