• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Shell scripts are getting hung frequently  RSS feed

 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

My client's applications are running on a very old version of Linux (RHEL 5.5). Since last 2 months, many of the script files written in Unix Shell Scripting language are getting hung. Is there any specific area / reason to look for to investigate the cause of the scripts getting hung.

Any hints/help in this regard will be of great help!!

Regards,
Pankaj
 
lowercase baba
Posts: 12705
50
Chrome Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
your first step should always be the logging - assuming there is any.  if not, can you add some?  a few simple echo statements should help you figure out where it is hanging...

has the script changed recently (i.e about two months ago)?  Has anything the script does/calls/talks to/looks at changed?  You need to figure out where to focus your investigation, and the logging is your best bet.

If you can't look at or add any, then try and figure out how far the script does get...it always frustrated me that we never had a shell debugging too...but sometimes you can even run the commands manually, one at a time, to figure out what might be hanging...but that depends on what exactly each command does...
 
Pankaj Poshirkar
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Fred for setting the approach for me.

Regards,
Pankaj


fred rosenberger wrote:your first step should always be the logging - assuming there is any.  if not, can you add some?  a few simple echo statements should help you figure out where it is hanging...

has the script changed recently (i.e about two months ago)?  Has anything the script does/calls/talks to/looks at changed?  You need to figure out where to focus your investigation, and the logging is your best bet.

If you can't look at or add any, then try and figure out how far the script does get...it always frustrated me that we never had a shell debugging too...but sometimes you can even run the commands manually, one at a time, to figure out what might be hanging...but that depends on what exactly each command does...

 
Bartender
Posts: 20310
110
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, there are supposed to be shell debugging aids, but they're so obscure and arcane that I've always resorted to brute-force echo commands and the like.

But the shell interpreter isn't likely to hang. More likely invoke a program that is taking longer than expected, so some of the traditional performance tools may help on that.

RHEL 5 passed end-of-life 2-3 years back and has no ongoing support from Red Hat. If they're paying for RHEL, they really should consider migrating. There's some pretty horrible security exploits for Linux that have come out since RHEL 5 stopped getting updates.

Moving to RHEL 6 wasn't that hard for me - I think the primary challenge was switching my VMs from Xen to kvm. Moving to RHEL 7 is uglier, since it has systemd, so init scripts are deprecated and don't get me started on logging, but I finally moved just about everything to v7. v6 is itself due to be phased out soon, I think. RHEL 8 is in early Beta last I heard.

Actually, I run CentOS, since I don't need active Red Hat support and don't have the revenue stream to finance it. Close enough.
 
Bartender
Posts: 1002
16
Java Linux Mac OS X Spring VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, of your using bash then the following two commands placed at the top of the script will help



Then when you run the script it will;
  - set -v Display the shell input lines as they are read
  - set -x Display the commands and their arguments as they are executed

As for logging, I've just recently inherited a load of shell scripts (at work) which I did not like much.  So I've added logging and have been trying to add testing code using the bats (bash automated testing system).  The testing code is quite tricky and is work in progress ;-)

However since I've opted to write my own simple logging function, I've taken out the product specific parts and it can be seen below.  Works on Red Hat Linux, I tried on my Mac and seen a lot of date function errors.

Here's the code;

loggingUtility.sh


And here is an example of how to use;



I may put this into a git hub repository, time permitting.  
 
Tim Holloway
Bartender
Posts: 20310
110
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can also use the "logger" system command to record to the syslog subsystem.
 
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!