Tag Info

New answers tagged

2

By strict interpretation what you want to do is impossible. So the question is how much do you have to cheat to pull something like this off? You need bash, a PROMPT_COMMAND and two temporary files. you will also have to accept that the shell will not be updated until the command after completion of the background task. I would also recommend using make in ...


9

Users accounts are used not only for actual, human users, but also to run system services and sometimes as owners of system files. This is done because the separation between human user's resources (processes, files, etc.) and the separation between system services' resources requires the same mechanisms under the hood. The programs that you run normally ...


0

On Linux when we install a service it creates a user of its service name or similar to that so that it can't access others files.


6

I presume you're finding this list of users by checking /etc/passwd? This is totally normal - 'users' serve to carry a set of permissions, useful for locking down not just 'actual users' but also programs to certain areas of your system and tracking what they changed (same concept with groups). I've inserted one of my Raspberry Pi /etc/passwd files below ...


2

I tested this on 2 virtualbox setup, both using OS X as host, and assigned only 1 CPU for each client. 1 Ubuntu 14.04.2 In this setup, under X window environment, the behavior matched OP john@U64D:~$ ./a I'm the parent, my PID is 2682, my parent is process 2632 This sentence has been printed by process: 2682 my parent is process 2632 john@U64D:~$ This ...


0

Instant load: number of tasks running or waiting to run, or in another way, the number of tasks willing to run Load average: the measure above but exponentially averaged with previous samples of the same measure Both of these numbers are unbounded, and often much larger than N. To be clear: the load count on Linux includes threads, there is no doubt about ...


1

I found the problem. The kernel was compiled with grsecurity, which hides processes from other users. With default kernel everything works fine.


0

You can use the ability to run in background. To do it just put & at the end of your command. for example: $ gedit example.txt & [1] 12642 To list all processes in the background use the job command. $ jobs [1]+ Running gedit example.txt & To bring the process to foreground again use the fg command: $ fg %1 gedit ...


1

If you don't use wait(), the parent can finish before the child ever gets a chance to run. By the time the child process calls getppid(), the parent has exited, so the child is adopted by init. On a normal Unix implementation, the PID of init is 1, so you would expect it to say my parent is process 1 when this happens. But apparently VirtualBox changes this. ...


2

hidepid is a mount option for procfs that hides processes from other users. There are three settings: hidepid=0: Anyone can read the world-readable files in /proc/PID hidepid=1: Users can only access the /proc/PID directories and files that belong to their user. hidepid=2: The same as hidepid=1, but the processes of other users will not even be visible in ...


1

Seems you caused the high CPU load by sending it a signal. It is a kernel process, and there's an APAR for this issue: http://www-01.ibm.com/support/docview.wss?uid=isg1IZ97168 Be advised that the Ifix requires a reboot, as the fix is for the kernel. And as it's a kernel processes you cannot kill that process. For completeness, the full name of the process ...


0

If you want the path of the current executable, look at /proc/$PID/exe, ls -l /proc/$PID | grep exe


2

That seems like a DDoS trojan. Mostly those trojans are in cronjobs. Stop the cron daemon and check your /etc/crontab and /etc/cron.* files for multiple cronjobs that create those files.


0

Maybe I am over simplifying, but, can you just do this? ps -p <pid> -F tty Here is an example: $ ps -p 6947010 PID TTY TIME CMD 6947010 pts/0 0:00 ksh $ ps -p 6947010 -F tty= pts/0 Here is how you could determine to allow or deny access to a particular process: You first determine who owns the process and which pts device started ...


1

The reason the code is failing to run properly is the mismatch of AND and OR groups in the initial find command: find * \( -name '*.mkv' -o -name '*avi' -o -name '*mp4' -o -name '*flv' -o -name '*ogg' -o -name '*mov' ! -name '*-[900p-by-ZiriusPH].mkv' \) -print The binding for the parameters is to print the files matched for Name *.mkv OR Name *.avi OR ...


4

Instead of piping find into the loop, you could go through an intermediate file. That will ensure that the finding step and the looping step happen in sequence, with no overlap. Something like the following (I altered your expression for brevity): find \( -name '*.mkv' -o -name '*avi' \) >files <files while IFS= read file do ffmpeg -i "$file" ...


-2

$ ps -eaf | grep "xyz" | grep -v grep | awk 'print $2' | xargs kill


5

Run gedit as: gedit file.txt & The & at the end will cause the process to run in background and you will be able to use the current terminal interactively again.


4

You can use this command: gedit abc.txt & disown Source In the bash shell, the disown builtin command is used to remove jobs from the job table, or to mark jobs so that a SIGHUP signal is not sent to them if the parent shell receives it (e.g. if the user logs out).


0

Use GNU time (which has many more features that the builtin's "time" from bash) : $ sudo apt-get install time $ \time prog >/dev/null 0.00user 0.00system 0:00.00elapsed 0%CPU (0avgtext+0avgdata 2380maxresident)k 0inputs+0outputs (0major+119minor)pagefaults 0swaps The \time escaping explicitly asks not to use the builtin, /usr/bin/time would work too. ...


3

valgrind will give you this information, along with a number of other statistics on memory use (and it will tell you about memory leaks etc.). It will slow the program down somewhat, but since yours is a short-lived process it shouldn't be an issue. Here's example output from running ls: ==7051== ==7051== HEAP SUMMARY: ==7051== in use at exit: 351,689 ...


0

cgroups has a whole accounting suite to play with and is lightweight. https://www.kernel.org/doc/Documentation/cgroups/ https://www.kernel.org/doc/Documentation/cgroups/cpuacct.txt


0

As others have said there are many parts of a system that can be affected including the memory bandwidth, and these other parts of the system will also have their own scheduling and priorities. You could always use chrt -i 0 to give the compilation true idle priority. http://linux.die.net/man/1/chrt Or throttle the compilation using cgroups. ...


0

If the process priority (nice value) is low then it will not be interrupting a higher priority process. The reason you're seeing the low priority process still consuming a significant amount of CPU when the higher priority process is running is because the higher priority process is not that busy. Probably waiting on IO. Use chrt -i 0 to run the process at ...


3

cgroups were created for exactly this reason. http://www.kernel.org/doc/Documentation/cgroups/ http://www.serverwatch.com/tutorials/article.php/3921001/Setting-Up-Linux-Cgroups.htm It takes a little while to familiarise yourself with them, and I believe you need root access to set them up, but it can all be scripted. The newer Ubuntus have a .conf file so ...


2

You don't need to open the log files in an editor to see what's flooding them. Just look at the last few lines: tail -n 999 /var/log/syslog | less Log files from a process always contain the process ID: Apr 10 00:00:01 harfang /USR/SBIN/CRON[345]: (root) CMD ( /usr/local/bin/midnight-stuff ) Apr 10 00:00:01 darkstar wibbled[1234]: I'm bored Apr 10 ...


3

There is actually a strong hint in the syslog snippet you posted. The end of the line Apr 10 00:53:37 MyMachine kernel: [11608.690733] [<ffffffffa08e4005>] ? ath9k_reg_rmw+0x35/0x70 [ath9k_htc] shows the stack trace is due to an unexpected error in a device driver named ath9k_htc. Hopefully, the kernel didn't panicked but the continuous repetition ...


1

You could use iptables and move that process into a cgroup: mkdir /sys/fs/cgroup/net_cls/block echo 42 > /sys/fs/cgroup/net_cls/block/net_cls.classid iptables -A OUTPUT -m cgroup --cgroup 42 -j DROP echo [pid] > /sys/fs/cgroup/net_cls/block/tasks


0

I think that you need to use following method.I am showing an example : Consider that I need to know information about firefox browser that is running on my Linux Box. I will follow below steps : Get PID of firefox : [shubham@system-dev ~]$ ps -aux | grep firefox Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ shubham ...


0

Toying with this three-in-one on OS X 10.9.5: sudo lsof | grep \ IPv | sort ; clear ; sudo lsof -U ; clear ; sudo netstat -a


3

If the PIDs are e.g. 340 and 520, then you can try the following: $ watch --interval 2 --difference "ps -p 340,520 -o pid,ppid,%cpu,cputime" Here watch will mark the difference of outputs running with 2 seconds interval, here we have used the output formatting -o option to get only process ID (pid), parent process ID (ppid), percentage of cpu utilization ...


0

The two standard tools to show process informations are ps and top (and htop which is similar/improved). Notes: Many program change the apparent name of the threads to something meaningful, the tools below can either display the binary name or that apparent name (check PID 1086 in the examples below). In the examples below, I have removed most process to ...


2

I don't believe there is a way in general. There might be for some specific OS. You said Unix/Linux, but perhaps you are interested in a solution for a particular OS? As an example, Solaris stores the processes argument in two locations. One is an immutable buffer in the kernel associated with the process. But because it's a kernel buffer, the length is ...


2

I already answered a similar question a few months ago. So see that first for technical details. Here, I shall just show you how your situation is covered by that answer. As I explained, I and other writers of various dæmon supervision utilities take advantage of how Linux now works, and what you are seeing is that very thing in action, almost ...


5

With bash: echo "$BASHPID" would give you the pid of the process that evaluates that echo command Note that (for instance after a enable -n echo) it is not necessarily the same as the pid of the process that is running that echo command. bash (or any shell) does its own soup with processes. It's not always useful to try and guess what process does ...


8

$BASHPID may be what you are looking for. BASHPID Expands to the process ID of the current Bash process. This differs from $$ under certain circumstances, such as subshells that do not require Bash to be re-initialized. As opposed to $$ ($$) Expands to the process ID of the shell. In a () subshell, it expands to the process ID of the ...


0

ionice can take a process group ID as an argument (-P switch), which, obviously, affects all processes (and threads) in the given process group. Once can find the process group ID by looking at the 5th field of /proc/<PID>/stat (or using ps). This setting is a bit more coarse than what I really wanted, but works well enough.


4

The parent process id (ppid) of a process cannot be changed outside of the kernel; there is no setppid system call. The kernel will only change the ppid to (pid) 1 after the processes parent has terminated - if the process did not respond to a signal that the parent was terminated. For this to happen, the process needs to have ignored various signals ...


0

I'm currently investigating a similar issue with one of our servers. The application logs show that it terminated following a signal 15 (SIGTERM). Browsing through the logs, I found that the server was rebooted at that time, which could account for the system sending a SIGTERM to all the processes.


-1

Try this as well ps ax | grep "program name, or part of it" You will get the right answer, but also a meaningless entry like: 11424 pts/3 S+ 0:00 grep --color=auto something Using awk to show only PID's: ps ax | grep "program name, or part of it"| awk '{print $1}' That will give you the PID's, but also the PID of the meaningles entry. This ...


3

There are multiple ways to do it depending upon your need. If you are doing it in a shell script for line in $(pidof avconv) do echo $line done If you are looking for a oneliner pidof avconv |perl -pne 's|\s+|\n|g'


7

You can just get it that way in the first place... ps -C avconv -o pid=


15

You could parse the output with sed, as suggested by @Sobrique, or with tr: pidof avconv | tr ' ' '\n' Another approach would be to use pgrep instead: $ pgrep avconv16616 16283 16279 16198 16175 16035 15073 14049


5

You can always use sed to insert some linefeeds pidof avconv | sed 's/ /\n/g' although perhaps a bigger question is - why do you need them on separate lines? It may be that there's a more appropriate answer.


1

Summary: The shell performs parameter substitution on strings in double quotes but not on strings in single quotes. $$ is the shell PID but the number you see depends on which shell evaluates it. Details: Let us consider each case, one at a time. [root@localhost ~]# echo $$ 16991 16991 is the PID of the current shell: let's call it the main shell. ...


0

Single quotes are strong quoted, which bash will read as parameters, instead of a string as double quotes are intended for. Invoking bash with the -c option will tell it to use non-string parameters as positional parameters. Since single quotes are not strings, they must be interpreted as positional statements. ...


1

Not mounting procfs sounds like a mistake. It doesn't really improve security, and Linux is designed to have /proc mounted. In particular, as you've found, /proc is how you find information about processes (on Linux, ps is just a pretty-printer for information found under /proc). If you have a good reason to prevent some applications from accessing /proc, ...


0

Per St├ęphane's comment, what I'm seeing is a thread, not a process. Threads are listed in the output from ps -L One can strace all current and future threads of a process with strace -f


2

ps gets all his information from the mounted procfs, so without procfs there is no source to gain that information. The only option I see is to mount proc for the call of ps/top and then unmount it, that minimized the risk.


2

This is a security feature, described in the PID namespace man page. While processes may freely descend into child PID namespaces (e.g., using setns(2) with CLONE_NEWPID), they may not move in the other direction. That is to say, processes may not enter any ancestor namespaces (parent, grandparent, etc.). Changing PID ...



Top 50 recent answers are included