Login or Register to Ask a Question and Join Our Community

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

Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Execution problem with Cron: Script works manually but not w/Cron. Why?
# 1  
Old 04-15-2015
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:

db2 connect to TASMQ02;
DATE=`date +%Y%m%d_%H%M%S`;
db2 call monreport.dbsummary> /db2storage/perfmon/perfmon_data/monreport_dbsummary_$DATE.out ;

This script works as expected when I execute it(./monreport_dbsummary.ksh) manually and I can review the monreport_dbsummary_$DATE.out file.
However, when I added this script to my crontab, it appears to run but produces absolutely nothing...the output files are all zeroes(empty).
Does anyone know what could be my problem? Can someone help to resolve this?
Here is the cron setup for the scripts I intend to run:

##Run the following monreport every 30 minutes from 4 AM to 10 PM daily
##Discontinue after the Test by commenting out the next 6 crontab line
0,30 04-22 * * * /db2storage/perfmon/monreport_pkgcache.ksh
0,30 04-22 * * * /db2storage/perfmon/monreport_dbsummary.ksh
0,30 04-22 * * * /db2storage/perfmon/monreport_currentsql.ksh
0,30 04-22 * * * /db2storage/perfmon/monreport_connection.ksh
0,30 04-22 * * * /db2storage/perfmon/monreport_lockwait.ksh
0,30 04-22 * * * /db2storage/perfmon/monreport_currentapps.ksh

Any and all help will be highly appreciated.


Last edited by vgersh99; 04-15-2015 at 03:31 PM.. Reason: code tags, please!
# 2  
Old 04-15-2015
Look at the bottom of the page at 'More UNIX and Linux Forum Topics You Might Find Helpful'
# 3  
Old 04-15-2015
It's quite possible that db2 is "interactive". You may have to redirect stdin, stdout, etc... to force things to work non-interactively. My guess is that it's the stdin that is giving you grief. Try redirecting using </dev/null.
# 4  
Old 04-15-2015
did you check your cron environment? did you try to add full path to db2 command?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Execution problem with Cron

Hi, I'm unable to understand why the grep command in cronjob works intermittently Expected output: Grep command to look for a particular string with today's date and exit from infinite while loop else it must sleep for 5 mins I'm using the following statement in my shell script, the... (9 Replies)
Discussion started by: charlie87
9 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. Shell Programming and Scripting

Execution problem with CRON job

HI, I have written an executable file in unix and I was able to execute it successfully but when I called this file with cron job it was giving error like "permission denied" and "No such file or directory". Please help in how cron calls the file and what permission is required on the file... (2 Replies)
Discussion started by: vipin kumar rai
2 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

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

7. AIX

Execution Problem with Cron

Guys, I am beginer in unix. There is a cobol file with fixed-width. I want to read the total Line, Word and character count. I have tried with wc-l unix command, but it returns '0'. Please advice me the correct command/steps to get the record count. Thanks in advance. (4 Replies)
Discussion started by: vibhar
4 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. UNIX for Dummies Questions & Answers

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 ] do sleep 900 done What's the... (5 Replies)
Discussion started by: dstinsman
5 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

Featured Tech Videos