-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 (note: I have my script now doing what I wanted, the issue is solved). On Sunday, 2018-02-11 at 09:01 -0500, Anton Aylward wrote:
On 10/02/18 04:29 PM, Carlos E. R. wrote:
Hi,
Is it possible to get the PID of the previous command launched and finished?
Example:
fetchmail .... echo "Posible PID of fetchmail was: $!"
Well, the value I get I know it was not the PID. The documentation says that "$!" gets the PID of the previously backgrounded process, so it is not what I want.
I don't think this is a good example for reasons of reproducibility.
Ah, OK I see your point. fetchmail is somewhat special, it can run as daemon. But it happens to be the program I'm interested in ;-) I call it manually, not as daemon.
And while looking for that I find that there is also ~anton/.fetchmail.pid
Ah, I will have to check if it exists in my system when I run fetchmail. [...] No, it doesn't.
But Oh, Wait, a LOT of programs that go into the background. We need on that doesn't What's very basic... ah right, 'cat' is pretty harmless so long as you pay attention to Rob Pike:
anton@main:~> cat - - & [1] 4068
What? The shell has just told us what the PID is. And more
Yes, but I needed that info in a script (note: I have my script now doing what I wanted, the issue is solved - see the rest of the thread).
anton@main:~> jobs [1]+ Stopped cat - -
can we get more info on backgrounded jobs on BASH? he man page says we can; it has a lot of references to handling jobs in the background
anton@main:~> jobs -l [1]+ 4068 Stopped (tty input) cat - -
I don't know if this is really an answer. I'm not sure what the real problem is. Although this is RTFM solution above, it was one of those things that was sitting in the back of my head though I've never had occasion to use it, sort of like how to change the barrel on a 105 howitzer in the field or navigate using a quadrant and compass. Lots and lot of garbage that I'll never have occasion to use. Like using MS-Windows ...
You can see that in the rest of the thread. I wanted, and I got it done, to parse the fetchmail log from only a particular manual session. And as i run two concurrent fetchmails, I had to differentiate each one by its PID. I can post the entire script if you are interested. - -- Cheers, Carlos E. R. (from openSUSE 42.3 x86_64 "Malachite" at Telcontar) -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iEYEARECAAYFAlqAyZMACgkQtTMYHG2NR9WCygCdGOVUcBXtQI5Omb9Jjcx2zeBA HoMAmgInbX0y6TJisU/YG9wZ5bcgpsad =bzkh -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org