• 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
  • Bear Bibeault
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Ron McLeod
  • Tim Moores
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Vijitha Kumara

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: 12734
51
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: 20568
120
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: 1008
18
IntelliJ IDE Java Linux Mac OS X Oracle Redhat Spring Tomcat Server 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: 20568
120
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.
 
You don't like waffles? Well, do you like this tiny ad?
global solutions you can do at home or in your backyard
https://www.kickstarter.com/projects/paulwheaton/better-world-boo
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!