LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 04-20-2012, 07:09 AM   #1
yawningdog
LQ Newbie
 
Registered: Sep 2009
Posts: 19

Rep: Reputation: 0
Bring back ping process


I'm monitoring my connection to a host using a running ping request. Somehow my shell window managed to get closed (I think I may have lost power) and now I cannot get the status of the ping. When I run the top command, ping is still running and remains the top resource hog, so it clearly is still pinging. (Not sure how that woked out, the terminal window closing but the process staying up/restarting.)

Can anyone tell me how to bring the process back up so I can view the status of the ping?
 
Old 04-20-2012, 07:24 AM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
When you say "the ping process" what exactly is the name of the process? What is the process ID (PID)? Is it in fact just "ping" or is it a script someone wrote that is doing what you call "the ping process"?

At command line if you type "ps -ef |grep ping" what does it show? If there is a ? in the tty column then it means the process has been backgrounded which is why it is still running. You can background any process by putting ampersand (&) at the end of the line. You can also put nohup at the start of the line to tell it not to hangup when the terminal disconnects.

nohup ping myserver &
Would leave the ping of myserver running forever in the background.

There are methods to background a process and pull it into the foreground but that assumes you're still on the terminal session that backgrounded it which you're not (even if you reconnect from same terminal - it is different session). One can use the "screen" utility to start a session that stays active when disconnecting the physical terminal and later reattach to that running screen session.

If it were me I'd simply find the original ping process, kill it, and start a new one. I can't really see much value in leaving a ping running forever though and some downside (as for example your high cpu usage). I'd suggest instead of running a permanent ping that you do something like a cron job that does a "ping -c 1" every minute. If it works everything is OK otherwise you could script it so it sends you an alert on failure.
 
Old 04-20-2012, 07:58 AM   #3
yawningdog
LQ Newbie
 
Registered: Sep 2009
Posts: 19

Original Poster
Rep: Reputation: 0
When I say "the ping process", I'm referring to the fact that the ping program has a viewable PID and therefore counts as a process. If I run ps -ef | grep ping, I get the following

root 28355 28343 0 Mar22 ? pts/4 28-22:30:57 ping 192.168.x.x
root 28357 28322 0 08:41 pts/3 00:00:00 grep --color=auto ping

I'm familiar with the ampersand and nohup tags, and I realize that what I'm asking seems unconventional. I'm also familiar with screen and in retrospect I wish I had used it, but I failed to realize that this would take as long as it has. I know how to stop the process and start a new one and I know that seems like the sensible thing to do. However I have my reasons for not doing this which are, to this subject, strictly academic.

My question stands. How to get the ping results back up to the console? I suppose that if I cannot get it back because the console session is irretrievable, then all is lost and I have to start over. But I want to make sure before I do that.
 
Old 04-20-2012, 08:32 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,790

Rep: Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304
you need to write the output of ping into a file and use tail to view it.
 
Old 04-20-2012, 09:01 AM   #5
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
I don't know of any way to get access back to a backgrounded process once you've closed the original session.

What you COULD try to get some data is run "lsof -p 28355" to see what if anything that shows you.

You COULD also use tcpdump to see the actual traffic to/from 192.168.x.x. Or to see all ICMP (ping) traffic:

tcpdump icmp -i any
 
Old 04-20-2012, 09:07 AM   #6
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
I doubt that the the terminal is truely closed since pts/4 is listed in PS. In any case, the past history of stdout and stderr is already consumed. To view the current output you could try attaching gdb to the process and duplicating stdout.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Trying to bring back a disowned process to foreground km_009 Linux - Newbie 9 04-18-2013 08:30 AM
Bring back JTR process yawningdog Linux - General 1 05-14-2012 05:59 PM
Bring my keyboard back! Isix Linux - Newbie 4 01-28-2009 09:05 AM
how do i bring back windows OMEGA-DOOM Linux - Newbie 6 11-15-2004 02:06 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:35 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
Open Source Consulting | Domain Registration