Tag Info

New answers tagged

3

From man jobs(1P): <current> The character '+' identifies the job that would be used as a default for the fg or bg utilities; this job can also be specified using the job_id %+ or "%%". The character '−' identifies the job that would become the default if the current default job were to exit; this job can also be ...


1

let me yank here the solution @jimmij pointed to , with minor modification . (gdb) attach <pid> ... (gdb) call open("/dev/null",O_WRONLY) $1 = 3 (gdb) call dup2($1,fileno(stdout)) $2 = 1 (gdb) call close($1) ... (gdb) detach ... for those not familiar with gdb , "attach" "call" "detach" are gdb commands . get information with "help attach" ...


-1

The following will prevent normal returns as well as error messages 2&>1 >/dev/null


4

One approach could be to attach a debugger to the process and make it open stdout on /dev/null: gdb --batch -ex 'call close(1)' -ex 'call open("/dev/null",2)' -p "$pid"


1

You can use gdb to do this: gdb --batch -ex 'handle all print' -ex 'handle all nostop' -ex 'handle all pass' -ex 'run' cat will run cat under GDB and print all signals, pass them to the program and not stop execution. Doing this for a background program is harder, as GDB will try and go into the background instead. You might be better off starting it with ...


2

Check the bash manual: When bash is interactive, in the absence of any traps, it ignores SIGTERM https://www.gnu.org/software/bash/manual/bashref.html#Signals Check the kill help text (help kill at a bash prompt): If neither SIGSPEC nor SIGNUM is present, then SIGTERM is assumed. ...


2

You can, but the shell tries hard not to die unless it's absolutely sure that's what is required. SIGHUP works (as does SIGKILL), and you can try this - kill -HUP $$ (If you prefer numeric signal identifiers the HUP can be replaced with 1.) The reason that SIGHUP works is that this is the signal that would have been sent when a serial line connection ...


0

After going through man bash got the whole picture. If I had read man before posting the question! BTW above one answer doesn't seem correct while other one falls short to clarify. So: The shell has an execution environment, which consists of open files inherited by shell at invocation, the file creation mode mask, shell parameters inherited from the ...


0

The processor (CPU) has a mode bit (bits). From privileged mode ring-0, the computer can run all instructions, and access all resources. The kernel runs in this mode. There are instructions to change mode, e.g. change to usermode ring-3 (ring-1 and ring-2 are not used). The instruction to move to privileged mode, are more complex. These are interrupts and ...


1

The OS has permissions on the directories and if they don't permit a user to create anything in /etc it would be a security hole if some other mechanism would have the OS open other files than it thinks it is doing. (If the user has the permissions there is no need to fool the OS, then she can just change the files). That permissions on /etc are normally ...


0

I think probably you're looking for how to list the files in the /proc/$pid/ directory of the process in which you are interested (at least, this would be the case on a linux machine). Within that directory you can find practically all of the information you need to duplicate/emulate the state of one process within another. You'll want to pay close ...


1

Under the hood, the way environment variables transit from program to program is through the execve system call, which loads a new program image from disk. (This image replaces the current program; there's another system call, fork, which duplicates the current program; functions like system combine fork, execve and a few other system calls to launch a ...


3

There's a tool called cryopid that lets you snapshot a running process so you can resume it later. I haven't tried, but I see no reason why you couldn't "resume" the snapshotted process while the original is still running. As terdon's comment implied, there's a lot of things to consider when snapshotting a process, so cryopid can be finicky; the best ...


1

The shell builtin set shows all variables, not just those that have been exported to the environment. If you want to add a variable to the environment, simply do export variablename in your shell.


0

I'm sorry but all these solutions does not support contab since the same command line will appear twice in the 'ps' result. So here is mine : ## Test pour voir si le même script tourne déjà ## Un fichier .pid est utilisé pour stocké le numéro de process ## Si le pid est en train de tourner alors on sort. lock_file=$0".pid" [ -r $lock_file ] && ...


0

You should be able to grab it with the jobs-command: ➜ ~ top [1] + 55990 suspended top ➜ ~ jobs -l [1] + 55990 suspended top


0

Though all of the suggestions work well I've found my alternative is to use screen, a program that sets up a virtual terminal on your screen. You might consider starting it with screen -S and then a sessionname.Screen can be installed on virtually all linux and unix derivatives. Hitting control a and c will start a second session. This would allow you to ...


0

A simple enough solution: Have process A exec a second process A first (call it A'). Then let A block forever. A' can start D, and D can restart A', and A sticks around the whole time as the parent.


-1

ps -e gives the list of all the processes running. Also there's this ps -elf.


2

On busybox, "ps" doesn't have a "-o" option, but "ps l" includes the RSS column. If the underlying O/S is Linux, you can also get more specific details for a given process from: cat /proc/PID/status The output looks like this: Name: ash State: S (sleeping) Tgid: 1990 Pid: 1990 PPid: 1 TracerPid: 0 Uid: 0 0 0 0 Gid: 0 0 0 0 ...


5

If you run ps -el instead of ps -ef, you'll get an S column with the process state. My guess is that the process is in state D, which means uninterruptible wait. In other words, the process is stuck in the messier parts of a device driver, and the kernel doesn't think it's safe to kill it until the device driver lets go of it. You sometimes see this with ...


0

You need to execute ulimit -c 0 in the script that starts the webserver, probably /etc/init.d/apache or /etc/init.d/httpd. Place it near the top, but don't make it the first line. Alternatively you can change the way the core dump is written, so that subsequent core dumps overwrite the previous instead of creating a new file. Add these lines to ...


0

One way could be to examine the files opened by that process. Of the types shown in the FD column of lsof: FD is the File Descriptor number of the file or: cwd current working directory; ... txt program text (code and data); So, try: lsof -a -d txt -p 212548 For scripts, this does show the path of ...


0

For anyone trying this in busybox where ps is heavily simplified and the output is different, this variant of Gilles' great answer works well: ps -o pid,user,comm,vsz,stat | awk '$4 != 0 && $5 !~ "Z"' As per Gilles' answer, the methodology here is to find processes that don't use any user memory (`vsz col == 0), and filter out zombie processes ...


0

What I do is, after having killed the process, do it again. Every time I do that the answer comes back, "no such process" allenb 12084 5473 0 08:12 pts/4 00:00:00 man man allenb@allenb-P7812 ~ $ kill -9 12084 allenb@allenb-P7812 ~ $ kill -9 12084 bash: kill: (12084) - No such process allenb@allenb-P7812 ~ $ Couldn't be simpler and I've been doing ...


4

Should I output to a temporary file, then copy it over the final file only if the backup works? Not copy but rename. But this is impossible for the backup script if it writes to stdout. It cannot even prevent the empty file from being created as that has already happened when the script starts. This must be done from the outside. if ./script.sh ...


5

If you have GNU Parallel you can do this: parallel do_it {} --option foo < argumentlist GNU Parallel is a general parallelizer and makes is easy to run jobs in parallel on the same machine or on multiple machines you have ssh access to. If you have 32 different jobs you want to run on 4 CPUs, a straight forward way to parallelize is to run 8 jobs on ...


0

You can, but it's tricky and fragile. There are several options, one of them is xargs. The problems encountered when relying on job control and signals are discussed in this interesting article, really a recommended read: http://prll.sourceforge.net/shell_parallel.html The guy apparently made a new tool prll that can take arbitrary shell functions to ...



Top 50 recent answers are included