0

I have run multiple commands in different time as background process.

wget -r url1 &
wget -r url2 &
..............
..............

The result of ps -e shows 2 process named wget---

     2552 ?        00:00:01 wget
     2576 ?        00:00:00 wget
     ......        .............
     ......        .............

Now, I want to kill the process which is executing url2. How can I know which process runs which url?

2 Answers 2

3

Instead of -e option for ps command, use -f option.

user1    14298 13518  0 00:11 pts/1    00:00:00 sleep 100
user1    14299 13518  0 00:11 pts/1    00:00:00 sleep 50

This way you will see the parameters passed to the command as well, in your case different URLs

1

If this was done in an interactive shell setting, the second backgrounded job can be killed with kill %2.

If this was done in a shell script, you can record the PIDs and signal them thusly:

#!/bin/bash
wget http://example.com/bigfile1 &
pid1=$!
wget http://example.com/biggerfile2 &
pid2=$!
# Time passes..
# Impatience intensifies...
kill $pid2

If you want to see the full command lines (and environments) of your current session, you can use ps ex.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.