The process appear again automatically after I killed it [closed] - linux

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I try to kill a process with sudo kill 30602. But after I killed it I use ps aux | grep gmond to check, it appear again with another pid.That's like:
ganglia 30997 0.0 0.1 121812 2128 ? Ssl 16:05 0:00 /usr/sbin/gmond --pid-file=/var/run/ganglia-monitor.pid
Whatever how I kill it, it just appear again with another pid, even with kill -9.
What's the problem? And how to solve this?

You should change the entry in the /etc/inittab file. Probably your gmond service entry is starting with respawn. It will respawn every time you kill the process.
Link: To disable the process you have to edit /etc/inittab and comment out that line. To inform init about this change you have to send a SIGHUP to init:
kill -HUP pid-of-init
The /etc/inittab file was the configuration file used by the original System V init daemon. The Upstart init daemon does not use this file, and instead reads its configuration from files in /etc/init directory.

Related

How to set the output of ^Z (Control-Z) to output the PID of the stopped process? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 months ago.
Improve this question
I start my script bash test.sh and then press Control-Z and get this:
^Z
[1]+ Stopped bash test.sh
All fine. But I want that the output also has the PID.
I know I can do this ps $(jobs -p) afterwards to get the PID. But how it is possible that the output of Control-Z prints directly the PID?
I don't think that's possible. That said, perhaps you can take a step back and clarify why you are hoping to do that?
Because what you can do is directly refer to the particular job with %1 (or %<n> more generally, if you have multiple background jobs) for several built-in commands (fg, bg, kill, ...):
$ sleep 30
^Z
[1]+ Stopped sleep 30
$ kill %1
[1]+ Terminated: 15 sleep 30
More details in man bash or here: https://www.gnu.org/software/bash/manual/bash.html#Job-Control-Basics

Change hostname to null in linux [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
I downloaded elf file on the server but, it checks whether the file is executing on the server or not.
By debugging it with gdb and i found that there is a 'gethostname' function and if the function returns 0 the file stop with the message 'Running on an illegal host'.
Searching from internet 'gethostname' return -1 when the hostname is null.
So how can i change my hostname to return -1 and execute the program?
or is there any ways to return -1 without changing my hostname to null?
If you know which hostname is accepted by the "elf file", you can change the hostname of your system with the "hostname" command.
If you don't want to change the hostname globally, you can run your program in a LXC container into which you can change the hostname.
If running a container is heavy or difficult, you can run your "elf file" in a brand new UTS namespace with a command like "unshare" :
$ sudo unshare -u /bin/bash # Run a bash in a new UTS namespace
# hostname foo # Change hostname in the new UTS namespace
# ... Run your program ...
# exit # exit the shell and go back to original UTS namespace

How to kill a running script from another script? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 years ago.
Improve this question
I have a a.sh script that executes a infinite loop with a list of commands in background in a Debian machine and I would like to use another script b.sh to end with a.sh. As far as I know pkill -f a.sh is one way of doing it, but I want to know if there is another way of doing it
man -k kill shows many commands to kill processes. Watch out (1) (general commands) and (8) (admin commands). At my system I get (manually filtered):
killproc (8) - Send signals to processes by full path name
docker-container-kill (1) - Kill one or more running containers
docker-kill (1) - Kill one or more running containers
kill (1) - terminate a process
killall (1) - kill processes by name
killall5 (8) - send a signal to all processes.
pkill (1) - look up or signal processes based on name and other attributes
skill (1) - send a signal or report process status
If you run a.sh from b.sh you can get the process id of a.sh
b.sh
a.sh & # Execute a.sh in the background
APID=$! # $APID is now the pid of a.sh
#do some stuff or wait
kill -SIGTERM $APID # Give the process a chance to shut down
kill -SIGKILL $APID # Certain kill
This way you can kill the particular instance of a.sh if you have multiple concurrent
instances.

How do I run `forever` from Crontab? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
I am trying to schedule node server restart on OS reboot (Ubuntu 16.04 LTS). I wrote:
crontab -u username -e
then I added following line:
#reboot /usr/local/bin/forever start -c /usr/bin/node /home/username/node/bin/www
I get the success message after saving or updating this file. There seems to be no effect on server reboot.
I'd wrap that into a bash script in the user's home directory's bin.
/home/username/bin/start_my_node_app.sh
Then in your crontab...
#reboot /home/username/bin/start_my_node_app.sh >/dev/null 2>&1
Though according to this article, #reboot may not work for non-root users.
https://unix.stackexchange.com/questions/109804/crontabs-reboot-only-works-for-root

kill remote process by ssh [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Improve this question
I can't directly access target host, need ssh as a proxy.
How can I kill a process from local use ssh ? I try this:
ssh root#$center "ssh root#$ip \"ps -ef|grep -v grep|grep $target_dir/$main|awk '{print \$2}'|xargs kill\""
it got error:
kill: can't find process "root"
And how to avoid error where process not exist ?
Suppose your process' name is name, then you can try something like this:
ssh hostname "pid=\$(ps aux | grep 'name' | awk '{print \$2}' | head -1); echo \$pid |xargs kill"
Use pkill -f to easily kill a process by matching its command-line.
ssh root#$center ssh root#$ip pkill -f "$target_dir/$main"

Resources