Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8174571
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T22:29:42+00:00 2026-06-06T22:29:42+00:00

my system is Ubuntu 10 here is my code: #!/bin/bash pid = `ps -ef

  • 0

my system is Ubuntu 10

here is my code:

#!/bin/bash
pid = `ps -ef | grep process_string | /usr/bin/awk '{print $2}'`
`kill -9 $pid`

pid is the process id of process_string(there is only one matched)

but when I run this sh,I don’t kill the process

how can I solve it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T22:29:43+00:00Added an answer on June 6, 2026 at 10:29 pm
    1. You can’t have space on either side of the assignment. In this case it’s trying to execute pid with arguments of = and the stdout of ps -ef ....
    2. The second line will try to execute the output of kill -9 $pid, you don’t want that.
    3. Better to use $(...) than backticks.
     #!/bin/bash
     pid=$(ps -ef | grep process_string | /usr/bin/awk '{print $2}')
     kill -9 $pid
    

    You may want to use pgrep to get the pid instead, or pkill or killall to just kill by name directly (be careful with that last one, as the name implies it will kill all instances of the named program).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just have a system crash and reinstall Ubuntu 11.10, and my code produces
I recently tried to install monit on Ubuntu Natty from source. Here's my code:
System Specs and task I am using Code::Blocks on Ubuntu 10.10 and playing around
I'm debugging my CUDA 4.0/Thrust-based image reconstruction code on my Ubuntu 10.10 64-bit system
I'm on a Linux Ubuntu 12.04 system. I have been using this code to
I would like to disable address space layout randomization (ASLR) on my system (Ubuntu
My system is Ubuntu 11.10. I've been following this guide somewhat: http://www.ozbotz.org/opencv-installation/ I also
I have installed KVM on my Ubuntu system. Using vmbuilder , I setup a
I have a problem with apache2 settings (Ubuntu system). I would like to run
I´ve got a nomral user called Teacher in my Ubuntu system and it has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.