Issue calling scripts through CRON.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Issue calling scripts through CRON.
# 1  
Old 01-07-2008
Issue calling scripts through CRON.

I have the following cron job in the crontab.

#! /bin/bash

25 15 * * 1-5 /export/home/svittala/scripts/scpt1.sh >/dev/null 2>&1
.

The problem that I am facing is - the scpt1.sh can be executed manually. But, it is not executing through CRON. Not sure what's the issue. Any hints?. Thanks.

Satish
# 2  
Old 01-07-2008
Syntax and actual data

Not sure why you have the /bin in your message. Not normally part of a crontab. That would be the first line of your scpt1.sh file

Another thought on the difference in execution - you might not be in bash as your interactive shell. Thus, the commands might be running ok because the syntax is good for ksh (or whatever).
>echo $SHELL will tell you your interactive shell.

Also, not sure hy you had a . (period) at the end of your crontab instruction line -- perhaps you were merely ending a sentence as you typed. But, you probably don't want a period.

Otherwise, cut/paste the entire crontab file and the program that will not run.
# 3  
Old 01-07-2008
I'd start with eliminating "/dev/null" from your vocabulary. Change that to "/tmp/scpt1.sh.out" instead and you will likely get your answer.

I think the answers to about 90% of our problems are in /dev/null...too bad it's a black hole!
# 4  
Old 01-07-2008
Issue calling scripts through CRON.

Per Joe's suggestion, I removed the # bash entry on the first line and also removed the /dev/null and instead redirected the output to a tmp file.

Now, it creates a tmp file with 0 bytes and ofcourse the script did not trigger. This is my simple script:

===============================

#! /bin/bash
. $HOME/.profile

# Informatica Settings
#. /ga/applsw/informatica/server/set_informatica_env.sh
# File Areas
# INCOMING_DIR=/home/applusr/e290147/incoming/
# LOG_DIR=/home/applusr/e290147/log/
# INF_SESS_DIR=/ga/applsw/informatica/server/SessLogs/
PMCMD_DIR=/applsw/informatica/server/powercenter8.1.1/server/bin/
INF_USER=E290133
INF_PASS=etlguy
INF_FOLDER=dev_HHSC_EADW
INT_SERVICE=hhsc_uce_dev_int_svc
DOMAIN=hhsc_informatica_uce_dev

# Log Files
LOG_DATE=`date +"%m%d.%H%M"`
LOG_FILE=${LOG_DIR}scpt1.log.${LOG_DATE}

# Return Codes for pmcmd
RETCODE_PROD=0


echo "################################################################################"
echo ""
echo "EXECUTING INFORMATICA WORKFLOW........"
echo ""
echo "################################################################################"


${PMCMD_DIR}pmcmd startworkflow -sv ${INT_SERVICE} -d ${DOMAIN} -u ${INF_USER} -p ${INF_PASS} -f ${INF_FOLDER} -wait wf_s_test2


RETCODE_PROD=$?

if [ ${RETCODE_PROD} = 0 ]; then
echo "################################################################################"
echo ""
echo "SUCCESSFULLY EXECUTED INFORMATICA WORKFLOW........"
echo ""
echo "################################################################################"
echo "scpt1.ksh completed processing successfully at "`date +"%m%d.%H%M"`"\n" >> ${LOG_FILE}
exit 0
else
echo "scpt1.ksh FAILED at "`date +"%m%d.%H%M"`"\r" >> ${LOG_FILE}
exit 0

fi
# 5  
Old 01-07-2008
Update on this issue

I just modified my cron to something like this:

45 16 * * 1-5 ls -ltr > /export/home/svittala/scripts/scpt1.sh.out

and it looks like it executed perfectly. Not sure whats the issue when I try to call a script.

If I put something like this in the command prompt:

/export/home/svittala/scripts/scpt1.sh > /export/home/svittala/scripts/scpt1.sh.out

it executes fine. Thanks.
# 6  
Old 01-07-2008
Question

I don't think joeyg was saying to remove the #!/bin/bash from the start of your script. I think he was pointing out that cron executes everything from bourne shell with a very limited environment. For instance, I doubt that $HOME will be available to the script.

Just change the redirect but leave the #! path at the start. Alternatively, specify the shell you want to run in the cron commandline. Add a -x flag to the shell to get more information if you need it.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Calling multiple scripts from another scripts

Dear all, I am working on script which call other shell scripts in a loop but problem is from second script am not able to come out. Here is the snippet:- #!/bin/bash HSFILE=/root/Test/Components.txt LOGFile=/opt/domain/AdminDomain/application/logs... (3 Replies)
Discussion started by: sharsour
3 Replies

2. Shell Programming and Scripting

Calling scripts from with scripts

Hi all, I'm wondering if you could give me some advice. I am new to scripting and am getting rather frustrated that i can get my script to call another script if certain criteria is met, via command line, but I cannot get the same script to work thru the cron jobs. My first script monitors... (8 Replies)
Discussion started by: echoes
8 Replies

3. Shell Programming and Scripting

Calling scripts from other script.

I need to call 3 different shell scripts from 2 different scripts, one is a perl script and other is Shell script. In Case -1 : The perl script is myperlscript.pl and the name of three shell scripts which need to be called from the perl script are a1.sh, a2.sh and a3.sh. Each shell script... (1 Reply)
Discussion started by: siba.s.nayak
1 Replies

4. Shell Programming and Scripting

Running scripts within scripts from cron

Hi all, I have set up a cron job which calls another shell script shell script which in turn calls a Java process. The cron tab looks so. 0,30 7-18 * * 1-5 /u01/home/weblogic/brp/bin/checkstatus.sh >> /u01/home/weblogic/logs/checkstatus.log The checkstatus.sh scripts looks like this. ... (4 Replies)
Discussion started by: sirbrian
4 Replies

5. Shell Programming and Scripting

Calling scripts within script

Hi, I have written a some six scripts to move large files and re-size them. This has been done step by step, taking backup, creating the new files, merging the files, removing the temporary files created. Since these files are around 500 MB, each step takes somewhere between 1 to 5 mins. ... (1 Reply)
Discussion started by: baanprog
1 Replies

6. Shell Programming and Scripting

Calling Multiple Scripts - stops after 1

I have created a script to call 2-3 shell scripts to be execute in succession, however, it seems that after the first shell script completes, the entire script exits out. Example: 1stJob.sh 2ndJob.sh 1st Job - FTP files from Mainframe to Unix using the following commands at the tail of... (1 Reply)
Discussion started by: CKT_newbie88
1 Replies

7. Shell Programming and Scripting

Difference between calling the sub scripts

What is the difference between calling the sub scripts of below two line. /home/scripts/devdb.sh . /home/scripts/devdb.sh sh /home/scripts/devdb.sh We are using the suse 2.0 version (4 Replies)
Discussion started by: kingganesh04
4 Replies

8. Solaris

difference in calling shell scripts

Hi I am getting some errors when i am running the shell script using the following syntax: >abc.sh but the same script works fine with the following syntax: >sh abc.sh wats the difference in both....please help thanks in advance. (6 Replies)
Discussion started by: arpit_narula
6 Replies

9. Shell Programming and Scripting

any possible solution on sql calling scripts

hi all, i have a function which will take i/p as a ddl sctipt as i/p and execute it, let function execute_sql { db_var="$1" v_cnt=`sqlplus -s XXXXX/XXXXX@aXXX << ENDSQL | sed -e "s/Connected\.//" -e "/^$/d" set pagesize 0 feedback off verify off heading off echo off serveroutput on size... (4 Replies)
Discussion started by: manas_ranjan
4 Replies

10. Shell Programming and Scripting

script calling other scripts hangs

I have a script that calls several other scripts in a specified order: # Loop over actions in specified order (STOP_ORDER or START_ORDER) and build and evaluate commands for command in $(eval print '$'${action}_ORDER) do printf "`date`\tExecuting ${action}_${command} = `eval print... (1 Reply)
Discussion started by: rein
1 Replies
Login or Register to Ask a Question