Can run script Manually, but not through Cron?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Can run script Manually, but not through Cron?
# 1  
Old 10-18-2005
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 is located in somefolder. If i run this script manually by simply invoking it, it runs without any issues. Any ideas?

#!/bin/ksh

# Source appropriate login information
. $HOME/somefolder/login_Cleanup.ksh

# Set the JOB_HOME (ie. where the lists of tables to archive are held)
export JOB_HOME=/home/oracle/somefolder

# Run the job.
$HOME/somefolder/OracleCleanup.ksh

# Rename logfile
mv $HOME/somefolder/log/OracleCleanup.log $HOME/chris/log/OracleCleanup.`date +%m_%d_
%Y`.log
# 2  
Old 10-18-2005
Script won't run via cron

Hello Madhatter,
I would suggest that you change the shell to the native shell for (most) systems, i.e. /bin/sh. The cron function may use this shell instead of the "K - shell" I would suggest starting there.
# 3  
Old 10-19-2005
On AIX (and HP-ux IIRC) the default shell is ksh, so that doesn't need to be the problem.

your cronjobs might be executed under a different user, so check the rights of ..../somedir to make sure it is accessible from within your cronjob.

bakunin
# 4  
Old 10-19-2005
This has been addressed in a FAQ entry.

either change
. $HOME/somefolder/login_Cleanup.ksh
to
. /wherever/home/is/somefolder/login_Cleanup.ksh
(and do similar things for other $HOME occurrances)

or

export HOME=/wherever/home/is

before the first use of $HOME

Cheers
ZB
# 5  
Old 10-19-2005
thanks for all the suggestions everyone! turns out that the list file wasn't fully qualified in the main script. it wasn't pathed at all, so that's why it only worked manually when i was in the current folder. I don't know how i didn't see that!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

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

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

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

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

5. Shell Programming and Scripting

Output differs when run manually and when cron job executes it

I get a different output when i manually run the .sh script and when it is run by a cron job. Please help me .. TMP1="/lhome/bbuser/script/wslog/sar.t1" TMP2="/lhome/bbuser/script/wslog/sar.t2" TMP3="/lhome/bbuser/script/wslog/sar.t3" OUTPUT="/lhome/bbuser/script/wslog/sar.out"... (8 Replies)
Discussion started by: nithinankam
8 Replies

6. Shell Programming and Scripting

Shell script not getting called through cron job but executes fine manually.

Hi, My shell script not getting called through cron job. The same works fine when executed manually. I tried to generate logs to find if the scripts has some errors related to path using following command- trying to execute .sh file every 5 mins: */5 * * * * /home/myfolder/abc.sh... (17 Replies)
Discussion started by: Dejavu20
17 Replies

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

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

9. Solaris

SFTP errorcode 1 when run on cron but runs manually

I am trying to run a sript on cron to SFTP data to a company. Private and public keys are set up. When I run this manully it works fine, however it was failing when run on cron. I have narrowed down the problem - it fails at the code that says if the error code is 0 then continue . . . I... (2 Replies)
Discussion started by: Heidi.Ebbs
2 Replies

10. Shell Programming and Scripting

check in unix shell script so that no one is able to run the script manually

I want to create an automated script which is called by another maually executed script. The condition is that the no one should be able to manually execute the automated script. The automated script can be on the same machine or it can be on a remote machine. Can any one suggest a check in the... (1 Reply)
Discussion started by: adi_bang76
1 Replies
Login or Register to Ask a Question