Page 1 of 2 12 LastLast
Results 1 to 10 of 18

Thread: Bash script hangs

  1. #1

    Default Bash script hangs

    Since installing Leap 15 I've had a bash script of mine hang several times. Today I tried to run strace on it and strace responded that the pid was in x32 mode and therefore wouldn't give me anything else. If I run strace on the script when it is running OK I get the normal output.

    I'm therefore not sure whether the script is in some kind of strange loop or is genuinely stuck.

  2. #2
    Join Date
    Jun 2008
    Location
    San Diego, Ca, USA
    Posts
    12,069
    Blog Entries
    2

    Default Re: Bash script hangs

    If you have no objection,
    You should post your script and describe how it's invoked.

    TSU
    Beginner Wiki Quickstart - https://en.opensuse.org/User:Tsu2/Quickstart_Wiki
    Solved a problem recently? Create a wiki page for future personal reference!
    Learn something new?
    Attended a computing event?
    Post and Share!

  3. #3

    Default Re: Bash script hangs

    I don't have any basic objection to posting the script but it is 6000 lines long so I doubt if anyone would want to go through it in detail. It is invoked via systemd.

  4. #4
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    25,972

    Default Re: Bash script hangs

    Quote Originally Posted by davidlwilcox View Post
    I don't have any basic objection to posting the script but it is 6000 lines long so I doubt if anyone would want to go through it in detail. It is invoked via systemd.
    OTOH, what do you expect from others here? Having a sort of script radar?

    The only thing we can do is giving hints on how to debug scripts. (But I guess that is nothing new to you?)

    So on important points (e.g. where your script starts en new phase in the process) insert echo statements to a log file. The statements should tell where you are in the script and maybe show some important values of parameters.
    Code:
    echo "parameter checking ends here, number of gurus is: ${NGURU}" >>/tmp/scriptlog
    I assume you get the idea.
    Of course fine tune after you get an idea where in the script the hang occurs.
    Henk van Velden

  5. #5

    Default Re: Bash script hangs

    I have different logging levels built into the script and I can monitor what state it was at when it gets stuck and I've analysed that information and there doesn't seem to be anything consistent. However what I find very strange is that strace won't give me anything when it gets into the stuck state.

  6. #6
    Join Date
    Jun 2008
    Location
    San Diego, Ca, USA
    Posts
    12,069
    Blog Entries
    2

    Default Re: Bash script hangs

    Still,
    You either have to provide a better description about where your script is hanging or provide the actual detailed info so people can evaluate what is likely happening themselves.

    If the script is too long, then post in a pastebin.
    But even so, just posting a long script by itself tells little.
    If your script is invoked without a problem, then you'll have to instrument your script, one main way is how henk describes... at various points in your script generate some output either to file or to stdout.

    TSU
    Beginner Wiki Quickstart - https://en.opensuse.org/User:Tsu2/Quickstart_Wiki
    Solved a problem recently? Create a wiki page for future personal reference!
    Learn something new?
    Attended a computing event?
    Post and Share!

  7. #7
    Join Date
    Jun 2008
    Location
    Groningen, Netherlands
    Posts
    20,473
    Blog Entries
    14

    Default Re: Bash script hangs

    Quote Originally Posted by davidlwilcox View Post
    I don't have any basic objection to posting the script but it is 6000 lines long so I doubt if anyone would want to go through it in detail. It is invoked via systemd.
    Eh, with 6000 lines in one single script, you don't have to doubt . But this says something very important: no person wants scripts of 6000 lines because you loose sight on the details. If in my case a script goes towards ~1000 lines, I tend to split it in multiple scripts that call eachother and return to the parent script, and I make sure that everything is in functions. To be honest, I can't think of anything that would need that much lines of bash.
    ° Appreciate my reply? Click the star and let me know why.

    ° Perfection is not gonna happen. No way.

    http://en.opensuse.org/User:Knurpht
    http://nl.opensuse.org/Gebruiker:Knurpht

  8. #8

    Default Re: Bash script hangs

    I would be more than happy to provide a better description of where the script is hanging if there was some way I could realistically monitor it. My logging suggests that the point at which it hangs is random and doesn't give me any indication as to where to add more logging.

    The real issue is the fact that strace isn't following it but simply coming up with this message which says something about the process being x32. However when I use strace on it when it is not hanging strace follows it quite happily. To me that suggests that there is something odd happening, plus the fact that it didn't start happening until I upgraded to Leap 15.

  9. #9
    Join Date
    Jun 2008
    Location
    Groningen, Netherlands
    Posts
    20,473
    Blog Entries
    14

    Default Re: Bash script hangs

    Quote Originally Posted by davidlwilcox View Post
    I would be more than happy to provide a better description of where the script is hanging if there was some way I could realistically monitor it. My logging suggests that the point at which it hangs is random and doesn't give me any indication as to where to add more logging.

    The real issue is the fact that strace isn't following it but simply coming up with this message which says something about the process being x32. However when I use strace on it when it is not hanging strace follows it quite happily. To me that suggests that there is something odd happening, plus the fact that it didn't start happening until I upgraded to Leap 15.
    How could we possibly say anything decent about "this message which says something about the process being x32." ? We need to see code, output, otherwise we cannot help you.
    ° Appreciate my reply? Click the star and let me know why.

    ° Perfection is not gonna happen. No way.

    http://en.opensuse.org/User:Knurpht
    http://nl.opensuse.org/Gebruiker:Knurpht

  10. #10

    Default Re: Bash script hangs

    Hi,

    6k lines of shell script code?! wow i haven't written shell script more than 1.5k but hey!
    So what change from previous openSUSE version to Leap?
    Is it some package or service or is your bash version is lower in the previous openSUSE release?
    All of them needs to be accounted for so you can trouble shoot.
    "Unfortunately time is always against us" -- [Morpheus]

    .:https://github.com/Jetchisel:.

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •