LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 08-26-2005, 11:53 AM   #1
nro
Member
 
Registered: Oct 2003
Distribution: Mandrake 9
Posts: 46

Rep: Reputation: 15
Bash Script - How do I make sure my program is still running?


Hello,
I have minimal(almost no) experience with linux and have ssh to a server with minimal access.
My objective is to keep a program running. If the server shuts down then it will stop. I want to make sure it stays live. I would appreciate any help with this.

Just a note: I don't really know anything about cron jobs, just that they exist. Would this be a solution?

Thanks,
Mike
 
Old 08-26-2005, 11:59 AM   #2
abisko00
Senior Member
 
Registered: Mar 2004
Location: Munich
Distribution: SuSE, Ubuntu
Posts: 3,511

Rep: Reputation: 58
I think I remember to have used 'nohup <command> &'. This should run the command independent from the existence of the console you used to start it.
 
Old 08-26-2005, 12:19 PM   #3
nro
Member
 
Registered: Oct 2003
Distribution: Mandrake 9
Posts: 46

Original Poster
Rep: Reputation: 15
How do I stop a command like that?
 
Old 08-26-2005, 12:33 PM   #4
abisko00
Senior Member
 
Registered: Mar 2004
Location: Munich
Distribution: SuSE, Ubuntu
Posts: 3,511

Rep: Reputation: 58
You need to know the process ID (e.g. ps ax | grep <command>). Then you can send the stop signal with e.g. 'kill -19 <pid>'. -19 is equivalent to SIGSTOP, but there are many others (see 'kill -l'). I don't know which is to prefer.
 
Old 08-28-2005, 01:57 PM   #5
ghrellin
Member
 
Registered: Dec 2004
Location: USA
Distribution: Gentoo Linux
Posts: 41

Rep: Reputation: 15
An even easier way to get the process ID (PID) of your program is to do
Code:
ps -C [program name]
Then you can kill it if you want. Also, nohup [command] & just directs all output to nohup.out (the nohup part) and makes it run in the background (the &). To bring the program back from the background, you can type
Code:
fg [command name]
and to see which programs you started with &, type jobs. Whew. Little process control tutorial there.
 
  


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
Bash: Check if a program is running naimslim89 Programming 12 05-08-2012 10:24 PM
bash script running as daemon Satriani Programming 12 03-29-2011 05:23 PM
can i make a script or program make a phone call? nephish Linux - Software 2 08-15-2005 09:02 PM
Asking a C program to call a bash script sceadu Programming 4 07-28-2005 08:52 PM
Running two copy's of the same bash script AndiOliver Programming 2 10-06-2004 03:46 AM


All times are GMT -5. The time now is 12:47 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration