LinuxQuestions.org
Help answer threads with 0 replies.
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 06-21-2009, 02:22 AM   #1
marigon
LQ Newbie
 
Registered: Jun 2009
Posts: 2

Rep: Reputation: 0
Question how to keep a program running


another newbie here, struggling with my dedicated Linux server.

My question is: I have a custom installed program that needs to run 24/7. Before I was able to keep it running with nohup command. But after the upgrade, something keeps terminating the program every few days. Being a total newbie, I don't think I will be able to investigate what keeps shutting down my program.

My question is: what are my other options? What else can I use to keep my program running all the time? My server runs on Centos 5.3, have a WHM and I also have some very basic underatnding how to use SSH and putty. Thanks
 
Old 06-21-2009, 02:50 AM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
You really haven't given enough information.

Perhaps something is "killing" the program. More likely, the program is just rolling over and dying itself.

SUGGESTIONS:
1. If possible, talk to the program's developer. See if she/he has any ideas why the program might crash, and if he/she has any suggestions for troubleshooting the problem.

2. If the program has logging, be sure to enable it. Look for the last log entries before it stops for potential clues as to why it's stopping.

Finally...

3. Run the program in gdb. If the program is actually crashing, you might be able to get a stack trace of where it crashed (and, consequently, clues as to *why* it crashed).

'Hope that helps .. PSM
 
Old 06-21-2009, 05:20 AM   #3
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,990

Rep: Reputation: 69
nohup will only block the HUP signal to the program; that's the signal that the operating system sends to the program when the terminal closes.

There are other signals that can kill your program; KILL, for example, can be sent only by another userspace program, and will terminate the program. KILL can't be blocked. Another option is SIGSEGV, which is sent by the OS when the program tries to access a part of it's virtual memory space that hasn't been allocated (ie dereferencing a wild pointer); this would always indicate a bug in the program. You can get a full list of signals from http://en.wikipedia.org/wiki/Signal_...ist_of_signals

Basically, you need to know what is killing the program. The easiest way to do that is either to run the program through gdb as paulsm4 suggests, or through strace (which may provide more detailed logging if this is a signal problem).
 
Old 06-21-2009, 07:07 PM   #4
marigon
LQ Newbie
 
Registered: Jun 2009
Posts: 2

Original Poster
Rep: Reputation: 0
thanks for the responses, I contacted the developer of the program (which actually IS indeed in testing stage), so there could be a bug in it. He said he would try to work it out, but in the meantime he suggested I write a script to start the program and nohup this script.

Unfortunately, I have no idea how to write such script. any ideas? the program is located in /usr/local/bin/program_name
 
Old 06-21-2009, 08:05 PM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
Code:
nohup /usr/local/bin/program_name > /var/log/program_name.log 2>&1 &
is the basic one-line script.
(redirect might not be needed if prog already does its own logging, depends on why it dies.)
I suspect what he meant was write a watchdog prog (short shell script) to run from cron every say 5 mins to check the target prog. If target is dead, restart program.
As it seems to be dying unexpectedly, I'd use

ps -ef|grep program_name

to check. More reliable than pid files etc.
 
Old 06-21-2009, 08:18 PM   #6
micxz
Senior Member
 
Registered: Oct 2002
Location: CA
Distribution: openSuSE, Cent OS, Slackware
Posts: 1,131

Rep: Reputation: 75
http://www.linuxquestions.org/questi...unning-329962/
 
  


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
Running program from terminal with & does nothing, program stops DittoAlex Linux - General 1 10-05-2007 02:35 AM
Running a program LinAck Linux - Newbie 1 07-02-2005 03:17 AM
running a program from within QT kooshball Programming 4 06-14-2005 06:08 PM
Running a program rj686 Linux - Software 16 10-10-2004 08:19 PM
Running a new program bananaman Linux - Newbie 4 04-08-2003 05:00 PM


All times are GMT -5. The time now is 06:43 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration