Linux - GeneralThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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.
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
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.