Tagged Questions
0
votes
1answer
15 views
Identify Tasks/Process which are 7 days old in linux
How can I identify the processes running since 7 days in Linux?
1
vote
1answer
62 views
How to kill the (last - 1) PID with bash
I know how to kill the last process with
kill $!
However I would like to kill the last−1 process, i.e. not the last one, but the one before the last one.
I tried
kill $$(($! -1))
but ...
10
votes
2answers
378 views
Why does bash show 'Terminated' after killing a process?
Here is the behaviour I want to understand:
$ ps
PID TTY TIME CMD
392 ttys000 0:00.20 -bash
4268 ttys000 0:00.00 xargs
$ kill 4268
$ ps
PID TTY TIME CMD
392 ttys000 ...
3
votes
2answers
265 views
Bash script wait for processes and get return code
I am trying to create a script which will start many background command.
For each background command I need to get the return code.
I have been trying the following script :
#!/bin/bash
set -x
...
0
votes
0answers
34 views
Forking two interactive bash processes causes parent process to stop or second bash to go background
If you fork (exec) two interactive bash processes within same parent process (from different threads) causes that parent process becomes stopped or second interactive bash goes to background which ...
2
votes
2answers
90 views
$BASHPID And $$ differ in some cases
I'm reading "BASH pocket guide of Oreilly".
It said:
The process ID of the current Bash process.
In some cases, this can differ from $$.
Above explanation , explained $BASHPID variable.
...
1
vote
1answer
75 views
How to ensure a process has started reading a file before continuing?
I'm trying to write a command to test that data is written to a file. My first approach was:
Start reading in the background.
Write some data to the file.
Wait for the reader to find a result.
...
2
votes
1answer
97 views
Can I transfer running process from dead ssh [duplicate]
Possible Duplicate:
How can I disown a running process and associate it to a new screen shell?
I have started (as expected) a long copy process from ssh shell (putty) which died due to ...
2
votes
4answers
433 views
How to view the output of a running process in another bash session?
I have left a script running on a remote machine from when I was locally working at it. I can connect over SSH to the machine as the same user and see the script running in ps.
$ ps aux | grep ...
0
votes
2answers
135 views
receiving command as a parameter in bash
I have a following simple script called single-instance that executes the given command if there is no process under that command running. If I hard-code the command after the else statement, it has ...
0
votes
2answers
347 views
Get PID of a function executed in the background
#!/bin/bash
function abc() # wait for some event to happen, can be terminated by other process
{
sleep 3333
}
echo "PID: $$"
abc &
echo "PID: $$"
I need to retrieve the pid of this function, ...
3
votes
1answer
158 views
bash: disable new process PID message
It may look like this: [2] 2847. I guess the first digit is just an enumeration of processes created from the shell. The second is the PID. Anyway, I never care about that information so it is just ...
2
votes
2answers
181 views
Quick and dirty way to run a process more than once
I am looking for very simple bash script that would allow me to launch a process a few times. What's essential to me is that after the processes terminate, everything will clean up automatically.
...
1
vote
1answer
99 views
How do you prevent user from opening a program?
I'm trying to write a script which prevents the concerned user from opening programs (mostly internet browsers) from being run during a certain time (like 1000 to 1200 hrs). This is like a ...
5
votes
1answer
204 views
Why is the following command killing a system?
Anyone understand the following code , running in bash ?
:(){ :|:& };:
It seems to be a "fork" bomb on Linux.
2
votes
2answers
221 views
add “check if fetchmail is running” to this script
while ! postqueue -p | grep -q empty; do
sleep 1
done
killall wvdial
this script checks if my mail queue is empty, then disconnects my modem. now i would like to add also a checking to fetchmail ...
2
votes
3answers
428 views
How can I test if a program is running from within a script
Let's assume that another user started a bunzip process, and I have a script that I'd like to start running after that bunzip finishes. What's the best way to check from inside my script that the ...
2
votes
4answers
541 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
1answer
915 views
All about ssh ProxyCommand
I am looking for an in-depth explanation of the following ProxyCommand, down to the nuts and bolts of its operation, please. Can you kindly completely dissect it for me and improve on it if you can? ...
0
votes
1answer
1k views
How to know how long a process has been running? [duplicate]
Possible Duplicate:
How to check how a long a program has been running?
I am interested in doing this purely using bash.
0
votes
1answer
1k views
Can you specify a separate trap in a subshell created with ()?
I'm writing a script that starts a subshell to go off and do some work. In a special case, the script needs to tell the subshell to cleanly stop what it's doing and exit early. However, my ...
3
votes
1answer
640 views
A tee >( process ) is truncating its stdout when writing a file
When I use tee to pipe stdout directly to a "specific block of code" (which then writes the modified data to a file), I always get the full complement of exptected output lines in the file.
...
13
votes
5answers
4k views
How can I close a terminal without killing its children (without running `screen` first)?
sometimes I run an app in the gnome-terminal, but then I suddenly have to restart gnome or something. I guess the answer to the question is also useful then I want to disconnect from SSH where ...
6
votes
3answers
12k views
Bash script to find and kill a process with certain arguments?
I want a script which kills the instance(s) of ssh which are run with the -D argument (setting up a local proxy).
Manually, I do ps -A | grep -i ssh, look for the instance(s) with -D, and kill -9 ...

