Script is not longer working in the crontab


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Script is not longer working in the crontab
# 1  
Old 07-20-2013
Wrench Script is not longer working in the crontab

This is the crontab it is supossed to be running everyday but it didnt

Code:
5 0 * * * /export/app/CO/opge/scr/Informe_parametros_colombia.ksh >/dev/null 2>&1

Inside the above script connects to a database and extract data to a flat file, manually i run the script at about 2 a.m. and Works OK, besides manually connect to the database OK
Code:
sqlplus copge/passw
SQL*Plus: Release 10.2.0.4.0 - Production on Jue Jul 18 02:32:56 2013
 Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.
 Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options
 SQL>

This is the code:

Code:
!/bin/ksh
#. .profile
 
#ORACLE_HOME=/softw/app/oracle/product/9.2.0;export ORACLE_HOME
#PATH=/usr/bin:/usr/sbin:.:/softw/app/oracle/product/9.2.0/bin; export PATH
#ORACLE_SID=COOPGE; export ORACLE_SID
 
fecha=`date +'%Y%m%d%H%M%S'`
sqlplus -s copge/passwd << fin
set feedback off
set linesize 1000
set pagesize 0
set head off
set trims on
set termout off
set serveroutput off
spool /export/app/CO/ppcs/datos/sdp/CO_Reportes/Imsi_$fecha.lis
alter session set nls_date_format = 'yyyy/mm/dd hh24:mi:ss';
select
num_telefono||'|'||
imsi||'|'||
asl||'|'||
cod_nir
from poge_paramred ;
spool off
exit;
fin

Thanks in advenced

Last edited by Scott; 07-20-2013 at 12:31 AM.. Reason: Code tags
# 2  
Old 07-20-2013
I would presume this:
Code:
!/bin/ksh
#. .profile

should be:
Code:
#!/bin/ksh
. .profile

# 3  
Old 07-21-2013
so you mean at 2 AM it runs ok manually ?What are the file permissions of script? Any error message received post here.
# 4  
Old 07-21-2013
thanks, i check out permissions the script and they were OK, maybe it has sth to do with the comment in the . . profile line, I'll try tomorrow and i will let you know
# 5  
Old 07-21-2013
Quote:
Originally Posted by alexcol
OK, maybe it has sth to do with the comment in the . . profile line,
It is the comment in the line where the profile is sourced in most probably, like Scrutinizer already said. You are falling for the Cron Error Number One.

I hope this helps.

bakunin
# 6  
Old 07-28-2013
OK Thanks you very much for your help and your infremation

I uncommneted the line:
Code:
. .profile

then schedule the next execution but didnt work, at first glance comparing with another script which worked succesfully i found fecha var fecha is not exported, that could be the problem ?

Code:
export fecha=`date +'%Y%m%d%H%M%S'`


Last edited by Scott; 07-28-2013 at 12:41 AM.. Reason: Code tags
# 7  
Old 07-28-2013
Exporting the variable won't make any difference.

Is your oracle environment set? It's unlikely it will be set in .profile which you already sourced.

Code:
$ ORAENV_ASK=NO
$ ORACLE_SID=DB1 #Your DB name here
$ . oraenv # The location of this should be in your path after sourcing .profile
The Oracle base for ORACLE_HOME=/oracle/product/11.2 is /oracle/u01
$ X=333 # regarding export question - this is not exported
$ sqlplus -s /nolog << !
connect scott/tiger
select $X as X from dual;
!

         X
----------
       333

$

Remove the /dev/null redirection from the cronjob, and check the user's mail to see what error(s) there are.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

Linux ksh script not working in crontab

I am Not sure why following script is not capturing the counts only when using crontab !! when I run it fromt he command line it is fine ! what is missing here ! #!/usr/bin/ksh host=`uname -n` tdate=`date` userid='dbid/password' totalevents=`sqlplus -s $userid << - set timing off ... (1 Reply)
Discussion started by: mrn6430
1 Replies

2. Shell Programming and Scripting

Script not working via crontab

Hi, I have written one script which is connecting to the the database and generating one CSV, it is running fine when i ran it manually though it is throwing any warning but CSV is generating and working fine but same script when i have configured in crontab not working and giving error, kindly... (1 Reply)
Discussion started by: ash1234
1 Replies

3. Shell Programming and Scripting

Script not working via crontab

Hi, I have written one script which is connecting to the the database and generating one CSV, it is running fine when i ran it manually though it is throwing any warning but CSV is generating and working fine but same script when i have configured in crontab not working and giving error, kindly... (6 Replies)
Discussion started by: ash12345
6 Replies

4. Red Hat

Script not working if crontab scheduled

Hi all, I'm working to a script with /bin/bash shebang. The script works perfectly if I run from command line. The script runs under a non root user and inside the commands are set with sudo command in a such a way they can be run under root, for example (first rows of the script):... (5 Replies)
Discussion started by: idro
5 Replies

5. Shell Programming and Scripting

Script not working in crontab

Hi I have created a script. Which i have configured in cron to make it run in every 2 min. But script is not running. If I checl the cron log at /var/cron/log .it shows its running in every 2 min. Below is the command which i configured in crontab. But I am not able to find the way so that... (9 Replies)
Discussion started by: nandan8a
9 Replies

6. Shell Programming and Scripting

My script stops working when using crontab

I have made a shell script(/bin/sh) that starts a perl script (that I haven't made my self) that's starts a ssh session. The ssh session uses a private/public key to login so no password is needed. The Perl script works perfect. But when I put it in a cronjob (crontab) the ssh connection asks... (6 Replies)
Discussion started by: splinter_cell
6 Replies

7. Shell Programming and Scripting

Expect Script Not working with Crontab

I have the following expect script sitting on a Linux box. === #!/usr/bin/expect -f # # backup.expect # # Expect script to backup a firewall via a SSH session # # set firewall set username set password set prompt set filename match_max 50000 spawn ssh -l... (2 Replies)
Discussion started by: alagondar
2 Replies

8. Shell Programming and Scripting

script not working from crontab, executes individual

Hi, This script is working successfully when i executed from shell prompt, but the same script scheduled in crontab its not deleting the files, #! /bin/bash DAY_1=`(date --date='4 months ago' '+%Y-%m')` log=/tmp/cleant adir=/u01/app/oracle/admin/talon/adump... (4 Replies)
Discussion started by: saha
4 Replies

9. Shell Programming and Scripting

Script is not working when put in crontab

Hi there, this is part of my script: /usr/bin/cd /u01/oradata /usr/bin/cp `/bin/ls -1 . |grep -v "^DIMStemp01.dbf$" | grep -v "^DIMSts01.dbf$"|grep -v "^DIMStects01.dbf$"` /backup It's working fine when I manually run on telnet session. /bin/ls -1 . -- to list all the files inside... (2 Replies)
Discussion started by: *Jess*
2 Replies

10. Forum Support Area for Unregistered Users & Account Problems

my account is no longer working

my account mhm4 is no longer working (9 Replies)
Discussion started by: mhm4
9 Replies
Login or Register to Ask a Question