The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
any possible solution on sql calling scripts manas_ranjan Shell Programming and Scripting 4 11-22-2007 03:02 AM
Calling SQL LDR and SQL plus scripts in a shell script rajagavini Shell Programming and Scripting 5 11-05-2007 03:12 PM
script calling other scripts hangs rein Shell Programming and Scripting 1 09-07-2007 02:26 AM
Calling functions in scripts directly LiquidChild Shell Programming and Scripting 12 04-27-2007 03:28 AM
Calling SQL scripts through Shell Script madhunk Shell Programming and Scripting 18 06-14-2006 09:35 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 01-07-2008
Registered User
 

Join Date: Aug 2005
Posts: 11
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
Reply With Quote
Forum Sponsor
  #2  
Old 01-07-2008
joeyg's Avatar
Moderator
 

Join Date: Dec 2007
Location: Home of world champion Boston Celtics
Posts: 958
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.
Reply With Quote
  #3  
Old 01-07-2008
Registered User
 

Join Date: Oct 2007
Posts: 155
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!
Reply With Quote
  #4  
Old 01-07-2008
Registered User
 

Join Date: Aug 2005
Posts: 11
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
Reply With Quote
  #5  
Old 01-07-2008
Registered User
 

Join Date: Aug 2005
Posts: 11
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.
Reply With Quote
  #6  
Old 01-07-2008
Smiling Dragon's Avatar
Disorganised User
 
Join Date: Nov 2007
Location: New Zealand
Posts: 734
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.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 01:25 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0