New answers tagged

0

Read (man) about pipe(int pipefd[2]) syscall - it returns two file descriptors - one for read and one for write. Next fork two processes - you are still in the same (forked process - so you see returned pipefd[] array. Next if you want to emulate pipe in shell you must In 1st process: close file descriptor 1 (stdout) dup() read file descriptor received from ...


0

You know what a linux pipe is ? If not, read about it here. So, a very basic task is to spawn two processes and connect the output of one task to the input of the other. That is what your question is about. The question specifies which tasks should be used: who : list all users currently logged in, one per line. wc: a small tool to count stuff - words, ...


0

Use killsnoop killsnoop traces the kill() syscall, to show signals sent via this method. This may be useful to troubleshoot failing applications, where an unknown mechanism is sending signals.


1

Previous answers are excellent, pointing out that threads are processes inside the Linux kernel and that you can clone( ) any subset of the process state you like anyway. But I think it's helpful to remember that it matters how much context can be shared or must be saved uniquely, and how many cycles it may take for a context switch, which may depend on how ...


0

I solved following serial port related problems in ubuntu 18.04 as follows: Problem 1 : Cannot open /dev/ttyACM0: Permission denied Solution : Grant permissions to read/write to the serial port with this terminal command ---> sudo chmod a+rw /dev/ttyACM0 Here replace tty port with your respective ubuntu port. Problem 2 : Failed to open /dev/ttyACM0 (...


0

Odds are that if you are trying to avoid he licensing cost, restricting which CPUs the software runs on isn't going to impact the software's core detection. You can request that the software only run on some cores, but the software will detect all the cores and check that number against the license / permitted configuration. To make this work the way you ...


0

The other answer is correct, but a little short on details. root@xxx:~# ps -ef | grep mosquitto root 3083 1912 0 11:59 pts/0 00:00:00 grep --color=auto mosquitto Note that only one process is returned, with the command line grep --color=auto mosquitto. This is the grep mosquitto from your command line, to filter the ps output. Your shell most ...


0

Your process doesn't exist, Do such as : ps ax |grep mosquitto|grep -v grep Then you will not any process.


-1

expect is the tool for you. Read man expect. expect does programmed dialog with interactive programs.


4

The term for this is CPU affinity. You can use the taskset command to set it for individual processes. To run <command> on the first 6 cores (cores #0-#5) only: taskset -c 0-5 <command> [arguments for command] If the process is already running, you can set its affinity by PID instead: taskset -c 0-5 -p <PID of an existing process> If you ...


2

Yes, on RedHat systems, typically a person uses numactl While it cannot guarantee a process binds to a specific CPU (as it will permit binding to another CPU should the desired CPU be unavailable, it will configure the job launch to make the best effort to bind and (if the process sleeps) rebind to the desired CPUs. Note that in this case, CPU means "...


0

What I like to do is write a specific tool that will do that for me. int main(int argc, char * argv[]) { setuid(0); system("renice <params>"); } I compile and install in /usr/bin. Then I change the permissions with: chmod 4755 /usr/bin/my-renice Note that is not 100% secure if you have users who have access to that computer who ...


1

You need to monitor stdout, e.g. using grep, so, I don't know, maybe PIDFILE=/tmp/.pid.$$ ( while true; do ./program & echo $! > $PIDFILE # echo "Program restarted at $( date )" >> /var/log/program.log done ) | while read X; do echo "$X" if (echo "$X" | grep "search" >...


0

This can be seen from strace summary. e.g.: $ strace -ce trace=write -p $(pidof app) % time seconds usecs/call calls errors syscall ------ ----------- ----------- --------- --------- ---------------- 100.00 0.061558 17 3544 write ------ ----------- ----------- --------- --------- ---------------- 100.00 0.061558 ...


2

It's a bit late, but it could be helpful for others. What I did: cat /proc/PID/stack to get some direction. In my case it was connected with inode and filesystem: [<ffffffff83bbd6f1>] wait_on_page_bit+0x81/0xa0 [<ffffffff83bced9b>] truncate_inode_pages_range+0x42b/0x750 [<ffffffff83bcf12f>] truncate_inode_pages_final+0x4f/0x60 ...


0

I don't know if Solaris have it, and if have it how it behave, but on linux sort command work. You can use sort command like this: # With ps --sort ps U $USER -o comm,pid --sort pid | head -n1 systemd 2120 # With sort cmd ps U $USER -o comm,pid | sort -k2 | head -n1 systemd 2120 In my linux box it work. i can't test on solaris


2

$! contains the pid of the right most command in the last pipeline run asynchronously. Here, you'd just need to run exec twice: exec > >(tee -a mylog) out_pid=$! exec 2> >(tee -a mylog >&2) err_pid=$! But maybe you don't need to record those pids. Those tee processes will exit (upon see eof) when your script (and all the processes it ...


1

In the end, it is up to the operating system kernel if it allows "giving back" (virtual memory) pages piecemeal (it might be a mess to do so; and not that relevant in practice, a page that isn't used will soon enough get evicted from RAM anyway). For more or less the same reasons, the language's runtime may just keep stuff around (if you e.g. in C ...


1

CROND is a child process of crond; it gets created when a crontab entry is processed. $ ps -ef | grep -i cron UID PID PPID C STIME TTY TIME CMD root 2289 1 0 Feb12 ? 00:00:02 /usr/sbin/crond -n root 446475 2289 0 14:37 ? 00:00:00 /usr/sbin/CROND -n Process # 2289 (crond) is the parent process for ...


2

Releasing pages is possible in principle and in practice. malloc and free don’t necessarily result in reserved address space; they can be implemented using mmap and munmap, in which case the corresponding address space and any populated pages can both be returned to the kernel after munmap. It’s also possible for processes to reduce their allocated address ...


2

Something (or more than one thing) seems to have run that program twice. try ps ax -o ppid,pid,lstart,cmd to get start time of processes. And search scripts that may have started it. Also look at parent-process-id.


0

What you probably were reading was the 1, 5 or 15 minute load average. This average would not go down instantaneously, but slowly, as the average load over the relevant time frame decreases. After 15 minutes, the effect of the process that you killed would no longer affect any of the load averages. Relevant manuals on your system: man uptime; displays the ...


0

Awesome work on the bash scripts, thanks for sharing! In the bash psig.sh I had to change line 202 for it to work on Ubuntu 20.04. --table seems to have been deprecated so I changed it to -t. before ~/bin$ psig.sh 2625 PID: 2625 Name: file.so Signals caught: --------------- Signal 15: SIGTERM Signal 11: SIGSEGV Signal 8: SIGFPE Signal 7: SIGBUS Signal 6: ...


0

Is my explanation correct? No. The sorts are blocked before even being started (the subshells which would execute the sorts are blocked when trying to open the fifos). And they're only blocked until the other side of the fifo is opened too, no need to read anything from it. If you try mkfifo /tmp/fifo; true > /tmp/fifo, the true will be blocked, even if ...


-1

You can use an opensource cross platform tool called sysdig. This tool will show you all the commands that where executed by users, directories that were visited by users. How to install and use sysdig instructions found here


0

I don't have Zoom installed, so I can't check myself. But a quick Google gave me this link How to disable Ibus autostart? (Which is a prerequisite of Zoom). Maybe the suggestions there will help you.


0

Sometimes "closing" a program just sends the kill signal to a child process related to the GUI or interface. But the main process (parent) is kept alive. Try using htop to identify the main process and kill it.


2

I think the easiest way would be to have the script check for the presence of a certain file. Then, in the while statement, sleep many times in shorter intervals. If you use seconds as your short interval, you would use a for loop that runs 300 times (=5 minutes). pseudo-code: for x=1 to 300 sleep 1 second check_if_certain_file_exists done From outside, you ...


0

Is this the only difference between SIGTERM and SIGKILL? No. A big difference between a SIGKILL and an uncaught SIGTERM is that the former will also wake up a stopped process (so it could immediately destroy itself), while the latter will only have effect after a SIGCONT. Simple example: $ sleep 1000 & sleep 1; kill -TSTP $! [1] 6455 [1]+ Stopped ...


20

Handling the timing is the script's responsibility. Even if that means using /bin/sleep today, it might not in the future, so killing that isn't actually guaranteed to work long-term. Well, I guess you can make that guarantee, but it's neater not to. My point is you shouldn't kill the sleep directly from outside the script, since the sleep is an ...


8

I like @sitaram's method of using ionotifywait. However, a similar thing can be done using more ubiquitous infra - the shell read command (which can take an optional timeout in Bash/ksh/Zsh) and a FIFO. The wait-loop looks something like this: mkfifo /tmp/myfifo while true; do read -t $((5*60)) <> /tmp/myfifo date echo "Executed every ...


4

If you have inotifywait available, you could setup a sentinel file (an empty file, with some unique name), and use inotifywait. I.e., replace the sleep with this: touch $HOME/.cache/sentinel inotifywait -t 300 $HOME/.cache/sentinel When you want to trigger this to execute "part X" right away, just touch $HOME/.cache/sentinel from some other ...


0

$! gives the correct value. $$ does not. Use $BASHPID instead See man bash: 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. Assignments to BASHPID have no effect. Not sure, why your kill -- -PID is not working, cannot reproduce. ...


0

If you have the commercial LSF from IBM as job scheduler, then you have also the option bpeek displays the stdout and stderr output of an unfinished job bpeek [-f] [-q queue_name | -m host_name | -J job_name | job_ID | "job_ID[index_list]"]


13

In another terminal, Kill the sleep process: pkill -f "sleep 5m" The loop will go on. If pkill is not available in your OS, you can get the PID using: $ ps aux | grep '[s]leep' username 14628 0.0 0.0 8816 672 pts/19 S+ 08:33 0:00 sleep 5m Then run kill PID to kill the process (here: kill 14628). This is good for manually killing ...


0

Some versions of pgrep (e.g., procps-ng) support a --runstates Z option.


1

As non-root, I shouldn't be able to get a faster priority. So, indeed a positive number is slower, negative faster: $ renice -n -10 6341 renice: failed to set priority for 6341 (process ID): Permission denied $ renice -n +10 6341 6341 (process ID) old priority 0, new priority 10 $ renice -n 0 6341 renice: failed to set priority for 6341 (process ID): ...


0

Threads What you're seeing in htop are Varnish treads, not Varnish processes. Varnish only has 2 long running processes: The main process (owned by the varnish user) The worker process (owned by the vcache user) The reason why you're seeing so many of them, is because Varnish wants the system to be responsive enough to handle a spike in traffic. Creating ...


Top 50 recent answers are included