New answers tagged

1

pgrep is the way to go; I wrote this mostly as a bash exercise, but in case it's useful to anyone else: It sets up a function that accepts one parameter -- a process name that presumably matches something in the ps -eo comm output. It reads the ps output, setting up an array of pids and parent pids for processes that match. Once that's done, it loops ...


1

You can use lsof command or netstat commands: lsof -i:9000 netstat -anlpo | grep 9000 Source: http://www.allaboutjava.club/linux/linux-find-an-application-running-on-a-given-port


2

If you're looking for the top level chromium process, it should be the one with parent process id of 1 (init), try using pgrep -P1 chromium to find its PID. This will work for many processes with a collection of threads where one wishes to signal the parent/top level process. Obviously the parent process will not be 1 if you start the browser from the ...


2

You could try with pgrep: pgrep -o chromium The -o flag will only print the oldest (least recently started) of the matching processes. If all your chromium instances are child processes of that parent process with pid 6167, then this must be the oldest chromium-browser process, therefore pgrep -o should print that pid. Tested with an apache instance: ...


0

Try something like pidof my_app >> /tmp/my_app.pid


0

You can use killall(1) (at least here on Fedora Linux). It has a raft of options. Personally, I use it almost exclusively when I know that there is just one process with the given name.


2

You can use pgrep with the -x flag: kill -9 $(pgrep -x P1) or better, with pkill you can do this: pkill -9 -x P1 with BSD pkill: pkill 9 -x P1


0

untested, but try #!/bin/sh nohup sxhkd </dev/null >/dev/null 2>/dev/null & nohup panel </dev/null >/dev/null 2>/dev/null & To completely disassociate them from each other


2

If you need in depth scheduling info, you could use one of these tools - perf SystemTap dtrace (I dont know what the state of the linux port is) sysdig All of these can tap into kernel hooks to display events such as context switches, interrupts, I/O, system calls etc.


2

You can get a lot of internal information about processes, the scheduler, and other components of the OS and the hardware by using cat /proc/... where ... can be many things. For instance, it could be a process ID, followed by a lot of specific information request, or scheduler debug information request, for example: cat /proc/sched_debug To see the ...


2

The ps command is a good place to start. It allows you to specify what information to display for a set of selected processes (possibly all processes). You can read the man page for detailed information on the available information you can get, which are specified as flags to the -O option. The following is a start for what you might want: ps -O "%mem ...


0

Partially. See ulimit which is usually a shell helper command. (In bash, help ulimit). You can limit its memory, total CPU cycles and time (but not a percentage), and size of files written by it. You can also use the nice command. But in reality, if there is nothing else demanding resources, nice won't have an effect. It only comes into effect when ...


1

For a command you run from the shell, read the shell documentation on ulimit. There is a ulimit() function that does the same thing in C. There are also various limits you can apply via implementation-specific methods. In FreeBSD, you can set limits per user in login.conf, or using a command called rctl. Some Linux distros use a limits.conf. There is a ...


1

You can apparently follow a process using strace. If you know the PID of the process then you can do: strace -o strace-<pid>.out -f -p <pid> Notice the -f switch. It will help you to follow newly created processes that are descendants of the process whose PID was used in the command, above. For information on strace see this question.


0

you can run ps -ef | grep ora_pmon | grep -v grep and it will give you the process listings that you need. You can simplify this output by using very basic sed or awk commands, according to your needs.


1

The easiest way is to enable system call auditing See the following link for details´╝î http://serverfault.com/questions/199654/does-anyone-know-a-simple-way-to-monitor-root-process-spawn If you're monitoring all processes, just remove the -F uid=0 part Logs are written to /var/log/audit/audit.log


0

#!/bin/bash declare -a bgpids cleanup() { for pid in ${bgpids[@]}; do kill -9 $pid done } trap "cleanup" SIGINT SIGTERM sometask & bgpids+=("$!")


1

It could be CPU consumed within a kernel process, driver, or interrupts. This is not an answer, but one way to approach solving it. Some details to this approach are Linux-specific. Install sysstat aka sar package and modify or add a sar-collection crontab (on RedHat systems, /etc/cron.d/sysstat): * * * * * root /usr/lib64/sa/sa1 -L -F -S XALL 10 6 Be ...


7

With zsh: pids=() trap ' trap - CHLD (($#pids)) && kill $pids 2> /dev/null ' CHLD sleep 2 & pids+=$! sleep 1 & pids+=$! sleep 3 & pids+=$! wait (here using sleep as test commands). With bash it would seem the CHLD trap is only run when the m option is on. You don't want to start your jobs under that option though as that ...


0

The free -tm command also shows the swap usage by files backed via tmpfs. If you can empty your /tmp folder, the memory usage of smem -t -k should be simular to free -tm.


-1

Edited the script and checked with a python code working fine for me.


0

This is due to lack of memory. You have slightly less than 300MB RAM free (free+buffers), and each new weblogic Java instance will be eating 3GB. There is a functionality of the Linux kernel called the OOM killer that kills a random process whenever there is insufficient memory. How to Configure the Linux Out-of-Memory Killer Have a look at that JAVA ...


2

Process handles are a Windows concept so as far a Unix and Linux are concerned, there is nothing to close in the first place. The parent process must however properly get the process exit status with waitpid or wait. When a process has stopped, i.e. is suspended but has not exited, it can be resumed and you can find a lot of information about it. When it ...


0

It can be that top is reading the whole usage of the physical CPUs, not of the virtual CPUs. It is also possible, that there are some processess running, that are hidden for the ubuntu user. Also try running ps aux. You can type the 1 number while running top to get detailed information about the CPUs usages. Here is the notation from man top point 2b: ...


0

You have 3 processes listed. The issue about sh in Unix is that is the Bourne shell. Many Unix has sh as default shell, and after that offers the Bourne again shell (bash) over it because it offers many options just sh don't. If you realised, the PID of your sh is lower than your bash. bash is running after sh, probably over it. ps appears because when it ...


0

It's an interesting trio you have there. Generally when you log in and run ps with no flags you will get your login shell and the ps program. By default ps will show all processes with the same EUID and same tty. So a shell and ps appearing is not terribly unusual. You have two interesting things: The parent PID for the first shell is PID 1 You have two ...


1

The sh utility is a command language interpreter that shall execute commands read from a command line string, the standard input, or a specified file. The application shall ensure that the commands to be executed are expressed in the language described in Shell Command Language ps displays the currently-running processes. This makes sense because we are ...


6

kill -STOP $PID [...] kill -CONT $PID


5

A port is considered "in use" whenever there are any sockets bound to it. They don't have to be in LISTEN state, just bound. Therefore the TIME_WAIT sockets that you see do count. It gets a little bit more complicated if any sockets are bound to addresses and ports. Different sockets are allowed to be bound to the same port if they're bound to different ...


6

You can access the return code of the last command executed with the special parameter $?. There is no documented standard (at least none that are widely adopted) for return codes other than "0" being success and non-zero being a failure. You will have to check the manpage of the specific command that you are running.


1

In general, it probably won't have a bad effect. However, Linux by default allows overcommitting memory. That means that if a process asks for memory, Linux will say "sure". Then, if it actually runs out of memory (including swap space), Linux will start killing processes to free up memory. So, if your process allocates 117GB but does not use most of it, it ...


1

Chrome browser spawns several threads at startup then spawns extra threads for each window and/or tab created subsequently. By default, killall sends a SIGTERM to all processed having a specific name ("chrome" in your case). But only the processes able to handle this signal will proceed with it. The ones that are not able to handle SIGTERM signal won't ...


1

you can use the command top to show process top to kill process kill PID_of_chrome


1

I tried it with 2 processes and it seems to work -- jai@jai-VirtualBox:/tmp$ sleep 100 & [1] 3996 jai@jai-VirtualBox:/tmp$ sleep 60 & [2] 3997 jai@jai-VirtualBox:/tmp$ pgrep -l sleep 3996 sleep 3997 sleep jai@jai-VirtualBox:/tmp$ killall -v sleep Killed sleep(3996) with signal 15 Killed sleep(3997) with signal 15 [1]- Terminated sleep ...


1

It is possible that one of the chrome instances is ignoring the SIGTERM signal, waiting for a second to confirm? killall -9 chrome may do what you want.


1

You can't get a PID of a process which is not currently running, so there is no meaning for PID of a scheduled job.


2

The short answer is no: once an application has allocated memory, and used it, it "belongs" to that application, and unless that application releases it nothing else can reclaim it. (This isn't as simple as a call to free() though since that just returns memory to the individual application's pool, not to the system.) Swap is supposed to help with this: ...


0

Get PID: #!/bin/bash my-app & echo $! Save PID in variable: #!/bin/bash my-app & export APP_PID=$! Save all instances PID in text file: #!/bin/bash my-app & echo $! >>/tmp/my-app.pid Save output, errors and PID in separated files: #!/bin/bash my-app >/tmp/my-app.log 2>/tmp/my-app.error.log & echo $! ...


2

To answer that question, you have to understand how signals are sent to a process and how a process exists in the kernel. Each process is represented as a task_struct inside the kernel (the definition is in the sched.h header file and beginns here). That struct holds information about the process; for instance the pid. The important information is in line ...


6

A zombie process is basically already dead. The only thing is that nobody has acknowledged its death yet so it continues occupying an entry in the process table as well as a control block (the structure the Linux kernel maintains for every thread in activity). Other resources like mandatory locks on files, shared memory segments, semaphores, etc. are ...


1

at reads the command to execute from the standard input. You are not sending the command to execute to at. You are executing your command and sending the output of your command to at. Try something like: echo 'nohup nice MY_PROGRAM > foo.out 2> foo.err < /dev/null' | at 05:23 The echo command will print the string 'nohup nice MY_PROGRAM' and ...


2

As the process is a child of the shell you opened over ssh, this process will be terminated as soon as you log out of the shell, e.g. by disconnecting. You can use different methods to work around this: Start the program with nohup (no hang up) and disown it: nohup somecommand & disown %1 This will redirect all ouput to a file $PWD/nohup.out, if ...


2

In order to have a non-interactive job respond to SIGINT, you need to create a handler for SIGINT: $ ( (trap "echo Got SigInt" SIGINT; sleep 60) & ) & [1] 13619 $ [1]+ Done ( ( trap "echo Got SigInt" SIGINT; sleep 60 ) & ) $ ps -o pid,pgid,args PID PGID COMMAND 11972 11972 bash 13620 13619 bash 13621 13619 sleep 60 13622 ...


0

top -H -p <process_id> This will list you the threads, associated with your process (i.e. process_id) [Used on Ubuntu. There is possibility that the option -H is not available on some of the linux flavors]


2

I don't know why changing the kernel name would have made a difference (perhaps sd*1 runs after sd* allowing a bit more time for work to get done?), but udev doesn't like long-running actions in events: Starting daemons or other long running processes is not appropriate for udev; the forked processes, detached or not, will be unconditionally killed ...


1

You can use ps for this, ps will report a snapshot of the current processes. What you're looking for specifically might be ps aux. a = show processes for all users u = display the process's user/owner x = also show processes not attached to a terminal http://unix.stackexchange.com/a/106848/149009 You could also use ps x -u user to see what ...


0

You could touch a file for each command and check on that file. Here is a simple example: #!/usr/local/bin/bash # Flag to knkow when completed finished=0; # The commands t run declare -a commands=('cmd1' 'cmd2' 'cmd3' 'cmd4'); # Fork all commands for cmd in "${commands[@]}"; do ./$cmd & done # Loop to wait for all processes to finish loop=0; ...


0

First try a simpler scenario such as only 2 processes FOO1 and FOO2, and if you were to run within a script for example named parent.sh: #!/bin/bash FOO1 & pid1=$! echo "Child PID=$pid1 launched" FOO2 & pid2=$! echo "Child PID=$pid2 launched" BAR exit FOO1 BAR exit FOO2 echo "Pausing to wait for children to finish..." wait $pid1 wait $pid2 ...



Top 50 recent answers are included