We’re rewarding the question askers & reputations are being recalculated! Read more.

Questions tagged [process-management]

Use this tag when the topic is about system process management. Commands used for this are like ps and kill -9 xxxx and service xyz start|stop|restart and htop, for example. Often used in conjunction with memory management.

Filter by
Sorted by
Tagged with
6
votes
4answers
1k views

Is there a utility for daemonizing processes as non-privileged user?

A thing I frequently want to do is launch some long running process or server as my own non-privileged user and then have a way to tell if it's still running and restart it if not. So for example I ...
6
votes
2answers
987 views

Process owner vs process user (Gnome's system monitor)

Gnome's system monitor has a "User" column in the Processes tab. There's also an "Owner" column, (that seems to be hidden by default). Most of the processes have the same values on both columns. ...
6
votes
3answers
4k views

Using `kill -s 0 $pid` vs `[[ -e /proc/$pid ]]` to detect if PID is running

One of the idioms often used to check if process is running is to use kill -s 0 $pid. My question is, does it have any upsides over using [[ -e /proc/$pid ]] construct? The script I'm writing is ...
6
votes
3answers
911 views

How to show quoted command list?

ps -o command shows each command on a separate line, with space separated, unquoted arguments: $ ps -o command COMMAND bash ps -o command This can be a problem when checking whether the quoting was ...
6
votes
2answers
2k views

Removing zombie process from the process table

Can somebody please explain when parent process receives the exit status of a dead child process via wait, who actually reallocates the memory of the child process and removes it from the process ...
6
votes
3answers
11k views

How to find how many cores a process is using?

I have a eight core machine. How can I find out how many cores are used by processes that I see in htop?
6
votes
2answers
6k views

Restarting Gnome Shell 3.28.1 on Fedora 28

Running newer versions of Gnome (on Wayland), you can't restart the shell with Alt+F2, entering r & then Enter - which used to restart the shell without logging the user out of the session. More ...
6
votes
2answers
5k views

How does systemd handle the death of a child of a managed process?

How does systemd handle the death of the children of managed processes? Suppose that systemd launches the daemon foo, which then launches three other daemons: bar1, bar2, and bar3. Will systemd do ...
6
votes
1answer
3k views

How to find out what is using swap on FreeBSD?

I'm trying to pinpoint what process(es) is eating swap on my FreeBSD server. I can only see how much is being used (top) but not what process is swapping its guts out. I tried searching Google for ...
6
votes
1answer
2k views

A script's background process is still alive after closing the terminal

This is more of a process management/signal handling question than a Bash question. It just uses Bash to explain the issue. I'm running a Bash script in which I run a background process. This is the ...
5
votes
4answers
3k views

A gzip process regularly runs on my system, how do I figure out what is triggering it?

For a while now, I have had the problem that a gzip process randomly starts on my Kubuntu system, uses up quite a bit of resources and causes my notebook fan to go crazy. The process shows up as gzip -...
5
votes
6answers
5k views

grep invading my ps [duplicate]

When I'm checking for some process, I usually write ps aux | grep myprocess And sometimes I get the output of eimantas 11998 0.0 0.0 8816 740 pts/0 S+ 07:45 0:00 grep myprocess if ...
5
votes
1answer
5k views

pgrep full match not work, only part, why?

I use pgrep from procps-3.3.10. If I have executable aout_abcdefgh_ver27, then pgrep aout_abcdefgh_ver27 returns nothing, while ps aux | grep aout_abcdefgh_ver27 returns the expected result: ps ...
5
votes
2answers
10k views

Get process age from command line [duplicate]

In linux, from /proc/PID/stat, I can get the start_time (22:nd) field, which indicates how long after the kernel booted the process was started. What is a good way to convert that to a seconds-since-...
5
votes
1answer
463 views

Is it the process that cleans itself on termination or the kernel?

Recently I found this in a powerpoint presentation: When a program is compiled and linked, the linker inserts some extra code in the program. It is this code that calls the main function about the ...
5
votes
1answer
4k views

What is the difference between exiting a process via Ctrl+C vs issuing a kill -9 command?

I know I can kill any process with kill -9 command . But sometimes i see that even if I have terminated a program with CTRL+C , the process doesn't get killed . So I want to know the difference ...
5
votes
1answer
2k views

Better way to kill all processes with a handle to some file

This kills every process with a handle to file /foo/bar (in bash): lsof /foo/bar 2>&1 | grep "/foo/bar" | sed "s/ */\\t/g" | cut -f 2 | while read PID; do kill $PID; done This does not seem ...
5
votes
3answers
20k views

Find the process id of a java application in a bash script (to see if the target application is already running)

I know there are a million questions on getting the process ID, but this one seems to be unique. Google has not given me the answer, so I hope stackexhange will help rather than close this question. ...
5
votes
1answer
1k views

SIGKILLing after a grace period

I've seen a lot of process managers that try to do this. It was my understanding that you should only use SIGTERM to kill a process. The process could take an unknown amount of time to clean up after ...
5
votes
3answers
2k views

How to find and print arguments of a command in ps?

sudo ps o gpid,comm reports something like 3029 bash but the command has parameters --arbitrary -other -searchword is there a way to display these arguments?
5
votes
2answers
1k views

How can I see i/o stats for a briefly running process?

For long running processes like init, I can do things like $ cat /proc/[pid]/io What can I do if I want to see stats for a briefly running process such as a command line utility like ls? I don't ...
5
votes
1answer
1k views

Why kernel threads are treated as processes

In output of the ps command like the one below (kthreadd,ksoftirqd,kworker) , i can see that there are some processes that don't have an executable file and i find out that's because they are kernel ...
5
votes
1answer
519 views

Understanding when background process gets terminated

I have a script which starts a number of background processes and if works fine when called from the cmdline. However the same script is also called during my xsession startup and additionally on ...
5
votes
2answers
686 views

Set process exclusivity in Linux

I am trying to measure the performance of a process. I have widely ranging performance measurements on small bit of single-threaded deterministic code that should perform the same every time. I would ...
5
votes
0answers
4k views

Detach a process from Sh (not Bash) or “disown” for Sh (not Bash)

Consider a shell script executed by Sh, not Bash (and I can't change it, and can't use a shebang, it's ignored). The & operator works, but disown $! does not and makes Sh complains “disown: not ...
4
votes
1answer
26k views

How to kill all processes owned by `user` on Centos 7? [duplicate]

I read in an online flash card that the command is: pkill -u bob $(pgrep -u bob) However, I think this is wrong. I think it's saying: Kill all the processed owned by bob, and 4572\n4600 Because: ...
4
votes
3answers
13k views

Find and kill the process that is using a serial port

I have multiple serial ports to each of which devices are connected. They are listed as /dev/ttyUSB*. Now, I need to make sure using a python script that no other process is using any of these before ...
4
votes
4answers
5k views

How to run java process to be seen not as 'java…' in processes list?

Is it possible to run a Java process in Linux in a way that it could be seen in ps as some sort of alias? It would be easier to restart it when it is down.
4
votes
2answers
3k views

How to run groups of commands in parallel?

I am trying to run groups of commands in parallel. There are 10 groups and each group has 3 commands. I want sequential execution within each group and parallel execution of the 10 groups. I am trying ...
4
votes
1answer
5k views

Orphan process's parent id is not 1 when parent process executed from GNOME Terminal

I start a new process from GNOME Terminal and then this process fork a child. But when I killed the parent process the orphaned process's parent id became something other than 1 which represent init -...
4
votes
2answers
1k views

What is meant by stack in connection to a process?

From the book Advanced programming in the Unix environment I read the following line regarding threads in Unix like systems All the threads within a process share the same address space, file ...
4
votes
1answer
2k views

Does a process invoking oom-killer kill itself?

Looking through syslog, I see lines like dd invoked oom-killer. Does this mean dd is being killed by the oom-killer or does it mean dd asked oom-killer to go kill another high memory process?
4
votes
1answer
319 views

What is the default or most commonly used multiprocessing model in Linux? Symmetric or Asymmetric?

What the multiprocessing model for Linux? Is there a default or most commonly used model? Is it similar or very different from say BSD or even the MS Windows kernel? If SMP is used normally, can ...
4
votes
3answers
179 views

Disallow File IO for a process except for FIFOs

How do you start a process that cannot do any file IO (opening / closing files, creating / deleting files, reading / writing files, etc.), except to read and write to pre-created FIFOs? (chroot will ...
4
votes
2answers
2k views

Why can't pgrep find scripts started via env?

For example: $ cat foo.sh #!/usr/bin/env bash while true; do sleep 1 ; done $ ./foo.sh & $ pgrep foo.sh $ Contrast with: $ cat bar.sh #!/bin/bash while true; do sleep 1 ; done $ ./bar.sh & $...
4
votes
2answers
10k views

Mysterious bash instances using a lot of CPU, how can I debug?

I seem to have multiple bash processes running that are taking up most of my CPU. This is the output of top -c: PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 20116 ...
4
votes
3answers
3k views

Intelligently switch between multiple BASH processes

Say you're in a directory and you want to check something in another directory, so you type bash to spawn a new shell so you can cd and check that thing and then type exit to get out and go back to ...
4
votes
1answer
4k views

What is a limit for number of threads?

I was wondering how many processes can I create on my machine (x64 with 8Gb of RAM and running Ubuntu). So I made simple master process which was continiously creating child processes, and that child ...
4
votes
1answer
405 views

Where are UID/GID of a process from, when not from the process's cred pointer?

Circumstances I'm having a lecture on "Cloud Security" at University, and am currently doing a project on virtual machine introspection. Goal of my exercise was to escalate privileges of some ...
4
votes
2answers
327 views

Can I attach a GUI process to a “surrogate X server”?

I have been in a situation where my desktop has crashed and become unresponsive. (In my case it was the Cinnamon DE, and I have yet to try cinnamon --replace from the commandline, BTW) I was using a ...
4
votes
1answer
97 views

When process groups are usually created?

I have a program that spawns many instances of other programs. I want to have a clean way to kill them after timeout, even if they spawn subprocesses, sometimes accidentally daemonize, etc. Right now ...
4
votes
1answer
850 views

SCHED_FIFO and SCHED_OTHER

I was trying to change linux process priority using chrt. I changed priority of one process to SCHED_FIFO from SCHED_OTHER. I could see some improvement in the perfomance. I run linux angstrom ...
4
votes
1answer
322 views

Reporting cpu hogs

Once in a while some program (ok, usually it's firefox) will start eating up nearly 100% of a processor's cpu time, heating up the processor and driving down by laptop's battery life. Since it's not ...
4
votes
2answers
1k views

How can I synchronize processes started in different TMUX panes?

Consider this: tmux split-window -d program1 program2 # this program depends on some side effects produced by program1 In this case, program2 will start before program1 is ready. program1 will send ...
4
votes
1answer
268 views

Discard stdout of a command for t seconds

I am working on some batch scripts involving the following: Run some non-terminating sub-processes (asynchronously) Wait for t seconds Perform other task X for some time Terminate subprocesses ...
4
votes
1answer
147 views

How to detect a desktop application hanging

I want to write a script that will detect whether a particular desktop application is responding and kill it. Is this possible? I know I've seen the GNOME desktop put up a "Application is not ...
4
votes
1answer
255 views

Why is CPU usage/time not showing in process information?

When I invoke top, the %CPU and TIME+ columns appear to be frozen and never update. Instead, the first few lines of the process list always look like this: PID USER PR NI VIRT RES ...
4
votes
1answer
929 views

Job queueing on a single machine

I have a shiny new server for running simulations on, with a pair of Tesla GPUs and 32 cores, running CentOS 7.2. I'd like for multiple users to be able to submit jobs to the server that get queued up ...
3
votes
4answers
2k views

Get list of processes that were forked off my currently running process?

I am writing a wrapper application to bash scripts and want the application to keep a track of which tools/processes have been launched from user scripts. I would like to know what is the best way to ...
3
votes
4answers
5k views

Killing all the process of a command except first process

I am sometimes stuck in a situation where a script/command kept in Cron runs more than once because of some reasons (the first instance is not completed fully, the second instance of the same process ...