25
Mar
Posted by Derek@TheDailyLinux in Tips and Tricks » Add Comment »
Example Usage of ‘jobs’ Command
This is one of those commands that hit me as “Whoa! How did I miss that?” — the jobs command. It simply lists the jobs currently running on the system. Unlike ps, it only lists what’s running in the foreground and the background. So, say you stop a process with ctrl+z and you want to later kill it, you can use the jobs command to quickly find it and then kill it off. For example:
# dd if=/dev/zero of=/dev/null ^Z [1]+ Stopped dd if=/dev/zero of=/dev/null # jobs [1]+ Stopped dd if=/dev/zero of=/dev/null # kill %1 # jobs [1]+ Terminated dd if=/dev/zero of=/dev/null # jobs #
You can easily kill off more than one process as well by simply including the %number after kill like:
# jobs [1] Stopped dd if=/dev/file1 of=/dev/null [2]- Stopped dd if=/dev/file2 of=/dev/null [3] Running dd if=/dev/file3 of=/dev/null & [4]+ Stopped dd if=/dev/file4 of=/dev/null # kill %3 %2 # jobs [1]- Stopped dd if=/dev/file1 of=/dev/null [2] Terminated dd if=/dev/file2 of=/dev/null [3] Terminated dd if=/dev/file3 of=/dev/null [4]+ Stopped dd if=/dev/file4 of=/dev/null #
As always, remember to read the man pages for more information.
Feel free to donate if this post prevented any headaches! Another way to show your appreciation is to take a gander at these relative ads that you may be interested in:
Here are some similar posts that you may be interested in:
There's 0 Comment So Far
Share your thoughts, leave a comment!