Part of the Shell script is not running via crontab, runs fine manually


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Part of the Shell script is not running via crontab, runs fine manually
# 8  
Old 10-04-2012
Hello Corona688,

I've tried whatever you suggested but no luck.

Code:
weblogic@[/SWIG/utilities]# date
Thu Oct  4 20:48:01 GMT+03:00 2012
weblogic@[/SWIG/utilities]# crontab -l
49 20 * * * /flexcube/user_projects/domains/WBFCSIM2/deployed_apps/SWIG/utilities/ATM_Restart_New.sh  2>/dev/null
weblogic@[/SWIG/utilities]# cat ATM_Restart_New.sh
#!/usr/bin/env ksh
. ~/.profile
# Use the following script to kill the currently running instance
# of the ATM scheduler, and restart the scheduler in nohup mode.
#Identify SWIG PID

PID=$(ps -ef |awk '/[S]WIG/ && !/ATM_Restart_New[.]sh/ { print $2 }');
#print "Original ATM process using PID=$PID"
# Kill the ATM
kill -9 $PID

sleep 30
echo $date

/usr/bin/nohup /flexcube/user_projects/domains/WBFCSIM2/deployed_apps/SWIG/utilities/run.sh 2>&1 > nohup.out &

weblogic@[/SWIG/utilities]# date
Thu Oct  4 20:53:22 GMT+03:00 2012
weblogic@[/SWIG/utilities]# ps -ef | grep SWIG
weblogic@[/SWIG/utilities]#

# 9  
Old 10-04-2012
# 10  
Old 10-04-2012
Hello Rdrtx1,

Yes I've tried your advice, please check the output's below.


Code:
weblogic@[/flexcube/user_projects/domains/WBFCSIM2/deployed_apps/SWIG/utilities]# crontab -l
49 20 * * * /flexcube/user_projects/domains/WBFCSIM2/deployed_apps/SWIG/utilities/ATM_Restart_New.sh  2>/dev/null
weblogic@a[/flexcube/user_projects/domains/WBFCSIM2/deployed_apps/SWIG/utilities]# date
Thu Oct  4 20:59:50 GMT+03:00 2012
weblogic@[/flexcube/user_projects/domains/WBFCSIM2/deployed_apps/SWIG/utilities]# crontab -e
weblogic@[/SWIG/utilities]#  crontab -l
01 21 * * * /flexcube/user_projects/domains/WBFCSIM2/deployed_apps/SWIG/utilities/ATM_Restart_New.sh  2>/dev/null
weblogic@[/SWIG/utilities]# grep PID ATM_Restart_New.sh
#Identify SWIG PID
PID=$(ps -ef | grep SWIG | grep -v -E "grep|ATM_Restart_New.sh" | awk  -v pid=$$ '$2 != pid {print $2'});
#print "Original ATM process using PID=$PID"
kill -9 $PID
weblogic@[/SWIG/utilities]# ps -ef | grep SWIG
weblogic 11075824 12058628   0 20:55:50  pts/0  0:01 /usr/java6_64/bin/java -cp ./:/flexcube/user_projects/domains/WBFCSIM2/deployed_apps/SWIG/build/SWIG.jar:./:/flexcube/user_projects/domains/WBFCSIM2/deployed_apps/SWIG/lib/GW_EJB_Bean.jar:./:/flexcube/user_projects/domains/WBFCSIM2/deployed_apps/SWIG/lib/j2ee.jar:./:/flexcube/user_projects/domains/WBFCSIM2/deployed_apps/SWIG/lib/xercesImpl.jar:./:/flexcube/user_projects/domains/WBFCSIM2/deployed_apps/SWIG/lib/xalan.jar:./:/flexcube/user_projects/domains/WBFCSIM2/deployed_apps/SWIG/lib/wlfullclient.jar::/oracle/app/Middleware1032/wlserver_10.3/server/lib/weblogic.jar:/flexcube/user_projects/domains/WBFCSIM2/deployed_apps/SWIG/lib/GW_EJB_Bean.jar com.iflex.sw.server.SWManagerInitializer ../config/
weblogic 12058628 10354770   0 20:55:50  pts/0  0:00 /bin/sh /flexcube/user_projects/domains/WBFCSIM2/deployed_apps/SWIG/utilities/run.sh
weblogic@[/SWIG/utilities]# date
Thu Oct  4 21:02:20 GMT+03:00 2012
[1] + Killed                   /usr/bin/nohup /flexcube/user_projects/domains/WBFCSIM2/deployed_apps/SWIG/utilities/run.sh 2>&1 > nohup.out &
weblogic@[/SWIG/utilities]# ps -ef | grep SWIG
weblogic@[//SWIG/utilities]# ps -ef | grep SWIG
weblogic@[/SWIG/utilities]#

---------- Post updated at 11:42 PM ---------- Previous update was at 11:37 PM ----------

Running Manually .

Code:
weblogic@[/flexcube/user_projects/domains/WBFCSIM2/deployed_apps/SWIG/utilities]# sh -x ATM_Restart_New.sh
+ . /home/weblogic/.profile
+ hostname -s
+ export HOST=appsrv2dr
+ export PS1=weblogic@appsrv2dr[$PWD]#
+ export EDITOR=/usr/bin/vi
+ export ENV=/home/weblogic/.kshrc
+ TMOUT=0
+ TIMEOUT=0
+ export readonly TMOUT TIMEOUT
+ PATH=/usr/bin:/etc:/usr/sbin:/usr/ucb:/home/weblogic/bin:/usr/bin/X11:/sbin:.
+ PATH=/usr/bin:/etc:/usr/sbin:/usr/ucb:/home/weblogic/bin:/usr/bin/X11:/sbin:.:/usr/java6_64/bin:/oracle/app/Middleware1032/Oracle_WT1/opmn/bin:
+ export PATH
+ HISTSIZE=500
+ HISTFILE=/var/log/hist/hist_weblogic.12058662
+ export HISTSIZE HISTFILE
+ export DISPLAY=localhost:1.0
+ export ORACLE_INSTANCE=/oracle/app/Middleware1032/Oracle_WT1/instances/wbohs
+ [ -s /usr/spool/mail/weblogic ]
+ echo [YOU HAVE NEW MAIL]
[YOU HAVE NEW MAIL]
+ + ps -ef
+ grep SWIG
+ grep -v -E grep|ATM_Restart_New.sh
+ awk -v pid=12058662 $2 != pid {print $2}
PID=11075638
11141320
+ kill -9 11075638 11141320
+ sleep 30
+ echo

+ /usr/bin/nohup /flexcube/user_projects/domains/WBFCSIM2/deployed_apps/SWIG/utilities/run.sh
+ 2>& 1 [1] + Killed                   /usr/bin/nohup /flexcube/user_projects/domains/WBFCSIM2/deployed_apps/SWIG/utilities/run.sh 2>&1 > nohup.out &
weblogic@appsrv2dr[/flexcube/user_projects/domains/WBFCSIM2/deployed_apps/SWIG/utilities]# 1> nohup.out

weblogic@[/flexcube/user_projects/domains/WBFCSIM2/deployed_apps/SWIG/utilities]# ps -ef | grep SWIG
weblogic 11141326 12189830   0 21:10:09  pts/0  0:01 /usr/java6_64/bin/java -cp ./:/flexcube/user_projects/domains/WBFCSIM2/deployed_apps/SWIG/build/SWIG.jar:./:/flexcube/user_projects/domains/WBFCSIM2/deployed_apps/SWIG/lib/GW_EJB_Bean.jar:./:/flexcube/user_projects/domains/WBFCSIM2/deployed_apps/SWIG/lib/j2ee.jar:./:/flexcube/user_projects/domains/WBFCSIM2/deployed_apps/SWIG/lib/xercesImpl.jar:./:/flexcube/user_projects/domains/WBFCSIM2/deployed_apps/SWIG/lib/xalan.jar:./:/flexcube/user_projects/domains/WBFCSIM2/deployed_apps/SWIG/lib/wlfullclient.jar::/oracle/app/Middleware1032/wlserver_10.3/server/lib/weblogic.jar:/flexcube/user_projects/domains/WBFCSIM2/deployed_apps/SWIG/lib/GW_EJB_Bean.jar com.iflex.sw.server.SWManagerInitializer ../config/
weblogic 11468850 10354770   0 21:10:28  pts/0  0:00 grep SWIG
weblogic 12189830        1   0 21:10:09  pts/0  0:00 /bin/sh /flexcube/user_projects/domains/WBFCSIM2/deployed_apps/SWIG/utilities/run.sh
weblogic@[/flexcube/user_projects/domains/WBFCSIM2/deployed_apps/SWIG/utilities]#

# 11  
Old 10-04-2012
quite possible that 'run.sh' needs a controlling terminal. You're starting it with 'nohup' - that might be an issue. Loose the 'nohup' and try.
Also, it might be that 'run.sh' needs some environment variables that you're not setting in the '~/.profile', but rather somewhere else...
Modify your script to:
Code:
nohup /flexcube/user_projects/domains/WBFCSIM2/deployed_apps/SWIG/utilities/run.sh 2>&1 > ~/run.out &

and examine the ~/run.out and see what's there.
# 12  
Old 10-04-2012
Hello Vgersh99,

Run.sh having the environment details. Please check the below output.

FYI : run.out doesn't having any output.

Code:
weblogic@[/flexcube/user_projects/domains/WBFCSIM2/deployed_apps/SWIG/utilities]# tail ATM_Restart_New.sh

PID=$(ps -ef | grep SWIG | grep -v -E "grep|ATM_Restart_New.sh" | awk  -v pid=$$ '$2 != pid {print $2'});
#print "Original ATM process using PID=$PID"
# Kill the ATM
kill -9 $PID

sleep 30
echo $date

/usr/bin/nohup /flexcube/user_projects/domains/WBFCSIM2/deployed_apps/SWIG/utilities/run.sh 2>&1 > ~/run.out &
weblogic@r[/flexcube/user_projects/domains/WBFCSIM2/deployed_apps/SWIG/utilities]# date
Thu Oct  4 21:20:11 GMT+03:00 2012
weblogic@[/flexcube/user_projects/domains/WBFCSIM2/deployed_apps/SWIG/utilities]# crontab -l
21 21 * * * /flexcube/user_projects/domains/WBFCSIM2/deployed_apps/SWIG/utilities/ATM_Restart_New.sh  2>/dev/null
weblogic@appsrv2dr[/flexcube/user_projects/domains/WBFCSIM2/deployed_apps/SWIG/utilities]# ps -ef | grep SWIG | grep -v grep
weblogic 11141326 12189830   0 21:10:09  pts/0  0:02 /usr/java6_64/bin/java -cp ./:/flexcube/user_projects/domains/WBFCSIM2/deployed_apps/SWIG/build/SWIG.jar:./:/flexcube/user_projects/domains/WBFCSIM2/deployed_apps/SWIG/lib/GW_EJB_Bean.jar:./:/flexcube/user_projects/domains/WBFCSIM2/deployed_apps/SWIG/lib/j2ee.jar:./:/flexcube/user_projects/domains/WBFCSIM2/deployed_apps/SWIG/lib/xercesImpl.jar:./:/flexcube/user_projects/domains/WBFCSIM2/deployed_apps/SWIG/lib/xalan.jar:./:/flexcube/user_projects/domains/WBFCSIM2/deployed_apps/SWIG/lib/wlfullclient.jar::/oracle/app/Middleware1032/wlserver_10.3/server/lib/weblogic.jar:/flexcube/user_projects/domains/WBFCSIM2/deployed_apps/SWIG/lib/GW_EJB_Bean.jar com.iflex.sw.server.SWManagerInitializer ../config/
weblogic 12189830        1   0 21:10:09  pts/0  0:00 /bin/sh /flexcube/user_projects/domains/WBFCSIM2/deployed_apps/SWIG/utilities/run.sh
weblogic@appsrv2dr[/flexcube/user_projects/domains/WBFCSIM2/deployed_apps/SWIG/utilities]# cat /flexcube/user_projects/domains/WBFCSIM2/deployed_apps/SWIG/utilities/run.sh
#!/bin/sh

export APP_SERVER_NAME=WEBLOGIC
export APP_SERVER_LIB=/oracle/app/Middleware1032/wlserver_10.3/server/lib
export GW_CALL=EJB
export PROJECT_DIR=/flexcube/user_projects/domains/WBFCSIM2/deployed_apps/SWIG
export JAVA_HOME=/usr/java6_64
export PATH=$JAVA_HOME/bin:$PATH:
CLASSPATH=./:$PROJECT_DIR/build/SWIG.jar:./:$PROJECT_DIR/lib/GW_EJB_Bean.jar:./:$PROJECT_DIR/lib/j2ee.jar:./:$PROJECT_DIR/lib/xercesImpl.jar:./:$PROJECT_DIR/lib/xalan.jar:./:$PROJECT_DIR/lib/wlfullclient.jar:

CLASSPATH=$CLASSPATH:$APP_SERVER_LIB/weblogic.jar
export CLASSPATH

$JAVA_HOME/bin/java -cp $CLASSPATH:$PROJECT_DIR/lib/GW_EJB_Bean.jar com.iflex.sw.server.SWManagerInitializer ../config/
weblogic@appsrv2dr[/flexcube/user_projects/domains/WBFCSIM2/deployed_apps/SWIG/utilities]# date
Thu Oct  4 21:21:41 GMT+03:00 2012
weblogic@[/flexcube/user_projects/domains/WBFCSIM2/deployed_apps/SWIG/utilities]# ps -ef | grep SWIG
weblogic@[/home/weblogic]# ls -l run.out
-rw-r--r--    1 weblogic winstall          0 Oct 04 21:21 run.out
weblogic@appsrv2dr[/home/weblogic]#

# 13  
Old 10-04-2012
I noticed your 'CLASSPATH' has './' in several places. When you run the 'run.sh' manually, do you always run it from your HOME dir? If you run it from ANY dir, will the run.sh still do what it's supposed to do?

Once again, it might be the case that 'run.sh' expects a controlling terminal and having 'nohup' and running it from cron might be an issue - I don't know.
Try loosing the 'nohup' in the script and running the modified script from cron - see what happens.

Last edited by vgersh99; 10-04-2012 at 03:40 PM..
# 14  
Old 10-04-2012
Removed the nohub still no luck. I've tried to run the run.sh from /tmp directory the script not working seems.

Code:
weblogic@r[/home/weblogic]# cd /tmp
weblogic@[/tmp]#  /flexcube/user_projects/domains/WBFCSIM2/deployed_apps/SWIG/utilities/run.sh 2>&1 > ~/run.out &
[1]     12189808
weblogic@[/tmp]# java.io.FileNotFoundException: ../config/switch.properties (A file or directory in the path name does not exist.)
        at java.io.FileInputStream.open(Native Method)
        at java.io.FileInputStream.<init>(FileInputStream.java:123)
        at com.iflex.sw.common.SWConfig.initializeProperties(SWConfig.java:63)
        at com.iflex.sw.server.SWManagerInitializer.main(SWManagerInitializer.java:78)

[1] +  Done                     /flexcube/user_projects/domains/WBFCSIM2/deployed_apps/SWIG/utilities/run.sh 2>&1 > ~/run.out &
weblogic@[/tmp]#

weblogic@[/tmp]# ps -ef | grep SWIG

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Job runs manually, doesn't work in crontab

I have a script (/home/admin/run_bkup.sh) that I can run manually to kick off an executable job. I want to run it in crontab, but it doesn't work. Here's the script: shell=/bin/bash today=$(date +"%m-%d-%y") /opt/CPsuite-R77/fw1/bin/upgrade_tools/upgrade_export mgt-svr-bkup-$today << EOF y... (18 Replies)
Discussion started by: df08388
18 Replies

2. UNIX for Dummies Questions & Answers

Script runs manually but not from crontab in UNIX

Hi Guys, I am executing the script called Delet.sh manually it is successfully completing the task but it is failing to run vi cron tab, I tried to pass PATH & .profile before execution but no luck, Any suggestions? Script below #!/usr/bin/ksh #set -x # Purpose : Delete folders file from... (9 Replies)
Discussion started by: Anilsa77
9 Replies

3. Shell Programming and Scripting

Script runs good manually but failing via crontab

Hello Gurus, I have written small script which will start the given service if its stop .Its running fine when manually executed but its unable to run from crontab. #!/bin/bash SERVICENAME=rsyslog service $SERVICENAME status > /dev/null SYSLOGSTATUS=`echo $?` COUNT=0 THRESHOLD=3 if ... (4 Replies)
Discussion started by: kapil514
4 Replies

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

5. Shell Programming and Scripting

Script runs fine manually but not in crontab

Hello Guys, I have scratched my head alot on this but couldn't find clue what's wrong. Can you please help me with this? My problem is as following. 1) When I manually execute following script it runs successfully with below output. bash-3.00# more smssend #!/bin/bash echo -e "<Request... (16 Replies)
Discussion started by: umarsatti
16 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. Shell Programming and Scripting

Script runs manually but not correctly from crontab

Hello all, I'm new here and have a question if you don't mind helping me. I have a script that will work if I kick if off manually but not from Cron. My cron entry is this: 05,20,35,50 * * * * /scripts/status.sh > /dev/null 2>&1 The first script (works fine) is this: #!/bin/sh # #... (14 Replies)
Discussion started by: hs3082
14 Replies

8. Shell Programming and Scripting

Script runs manually but not correctly from crontab

Hi all I have this inside a shell script (bash): cd DIRECTORY find . -maxdepth 1 | sed 's#./##' | /usr/bin/xargs -I '{}' chown -Rv '{}' /DIRECTORY/'{}' All the directories in this location are named after usernames, so it simply sets the owner to that of the username of the folder. It... (5 Replies)
Discussion started by: fakesy
5 Replies

9. Shell Programming and Scripting

Getting issue while running it from cron while manually working fine

Hello, I am working one one script where I am using the below code which is using to connect with MKS client when I run my script manually it works effiecently i.e. it connects with MKS client but when I run it from CRON it doesn't connect. 1)Can some one tell when it is running from cron... (1 Reply)
Discussion started by: anuragpgtgerman
1 Replies

10. Shell Programming and Scripting

Shell script runs fine in Solaris, in Linux hangs at wait command

HI, I have a strange problem. A shell script that runs fine on solaris. when i ported to linux, it started hanging. here is the core of the script CFG_FILE=tab25.cfg sort -t "!" -k 2 ${CFG_FILE} | egrep -v "^#|^$" | while IFS="!" read a b c do #echo "jobs output" #jobs #echo "jobs... (13 Replies)
Discussion started by: aksaravanan
13 Replies
Login or Register to Ask a Question