• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Shell scripts are getting hung frequently

 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 13089
67
Chrome Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...

 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 1155
20
Mac OS X IntelliJ IDE Oracle Spring VI Editor Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can also use the "logger" system command to record to the syslog subsystem.
 
reply
    Bookmark Topic Watch Topic
  • New Topic