LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-25-2016, 06:48 AM   #1
UserLinux123
LQ Newbie
 
Registered: Apr 2016
Posts: 2

Rep: Reputation: Disabled
Restarting service using command works fine but using the same command in shell script fails to restart


Script being used is shown below,

#!/bin/bash
ps auxw | grep ESDEMO | grep -v grep > /dev/null
if [ $? != 0 ]
then
casstart
echo "service was not running and has been restarted"
else
echo "service is running on $(hostname) as on $(date)"
fi
====================================================================

On executing this script to restart ESDEMO, I am getting the error - "/opt/microfocus/cobol/bin/casstart32: error while loading shared libraries: libcasmfsysv.so: cannot open shared object file: No such file or directory".

Verified PATH Environment variable.
"/opt/microfocus/cobol/bin" is set correctly.

Verified LD_LIBRARY_PATH.
echo $LD_LIBRARY_PATH
/opt/microfocus/cobol/lib


At the same time, I am able to start the service manually in putty just by giving casstart + Enter.
But getting the above mentioned error while executing using the script.

Please help in resolving this issue at the earliest.
 
Old 04-25-2016, 07:54 AM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,256

Rep: Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686
Normally in startup scripts it is better to provide the full path as depending on where and when the script gets executed, some items / variables may not be available.
 
Old 04-26-2016, 05:35 AM   #3
UserLinux123
LQ Newbie
 
Registered: Apr 2016
Posts: 2

Original Poster
Rep: Reputation: Disabled
Hi Grail,

Thanks for the response. I tried giving full path and placed the script in the /root path.
Now on executing ./xx.sh from root path, the service is getting restarted as expected.
But on using root crontab, restart is not working.

crontab -l
*/5 * * * * /root/xx.sh

xx.sh:
#!/bin/bash
export LD_LIBRARY_PATH=/opt/microfocus/cobol/lib
ps auxw | grep ESDEMO | grep -v grep > /dev/null
if [ $? != 0 ]
then
cd /opt/microfocus/cobol/bin
./casstart
echo "service was not running and has been restarted"
else
echo "service is running on $(hostname) as on $(date)"
fi

Please help on this.


The error that I am getting is:
CASMG99999E 0000,Message file missing. 12:15:01
CASMG99999E CF0038,casstart,ESDEMO,0000 12:15:01

Last edited by UserLinux123; 04-26-2016 at 07:23 AM. Reason: Added error message.
 
Old 04-26-2016, 10:26 AM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,256

Rep: Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686
Those would appear to be error messages from the program you are running. I would suggest going to their web site and looking for information as this is not longer an issue with linux
or the way the script is being run .. that I can tell

I would make 2 other suggestions:

1. Look up the pgrep function as it removes the need for multiple greps and the use of ps

2. Just supply the full path to run casstart instead of cd'ing into the directory - - /opt/microfocus/cobol/bin/casstart
 
Old 04-26-2016, 10:47 AM   #5
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,604

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
It is possible there is a missing environment variable (something like ESDEMO_HOME type of thing) that would point to a message file.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] [SOLVED] bash script: can echo command, command works if I type, but command doesn't work in script ... why? hopeless_n00b Linux - Newbie 9 02-26-2016 02:11 PM
[SOLVED] perl script runs fine from command line but fails when invoked by nagios andrest964 Linux - Newbie 7 10-04-2012 10:04 AM
service start httpd fails, manually starting with same command works jonboede Linux - General 1 02-19-2008 12:45 PM
Command works in shell, fails as a cron task angeljusto Linux - Software 3 06-13-2007 08:06 AM
Shell pgm works fine in command line but not in Crontab oracledba_raja Linux - General 2 11-24-2006 01:14 AM


All times are GMT -5. The time now is 07:01 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration