LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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, 05: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, 06:54 AM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,005

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
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, 04: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 06:23 AM. Reason: Added error message.
 
Old 04-26-2016, 09:26 AM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,005

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
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, 09:47 AM   #5
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
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 10 07-12-2018 05:57 AM
[SOLVED] perl script runs fine from command line but fails when invoked by nagios andrest964 Linux - Newbie 7 10-04-2012 09:04 AM
service start httpd fails, manually starting with same command works jonboede Linux - General 1 02-19-2008 11:45 AM
Command works in shell, fails as a cron task angeljusto Linux - Software 3 06-13-2007 07:06 AM
Shell pgm works fine in command line but not in Crontab oracledba_raja Linux - General 2 11-24-2006 12:14 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:19 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
Open Source Consulting | Domain Registration