2
votes
1answer
60 views

Is there any reason to use 'kill' instead of 'killall'/'pkill'?

Starting my adventure with Linux a couple of years back, most tutorials and older, more experienced colleagues suggested using the command 'kill', sort of like a replacement for the Process Manager ...
7
votes
4answers
848 views

How to check the process is already running or not

I want to check the particular process in already running or not. I refereed this Q&A. But I didn't get any specific solution. Following is the example that I tried: I have created abc.sh file ...
3
votes
1answer
64 views

Do something if a program is running

Is there something you can type into terminal so that it will run a command if a certain program is running? For example, if <Libre office is running> then sudo pkill <Libre ofice>. ...
1
vote
3answers
45 views

Terminating the Terminal process for a particular outcome

for example consider the following situation:: I need to print some numbers randomly one after the other with a time interval of 5 seconds between each, and I need to terminate the terminal process ...
0
votes
0answers
76 views

Option for GREP only non-default processes and services?

is there any option for grep only non default processes and services? I know how show all of this and export to file, but manual reading and deleting line by line is not ideal. :-) Thanks for your ...
1
vote
1answer
68 views

How would I make this bash script that displays certain system processes related features?

Basically I need to make a bash script that acts as a handy tool for diagnosing performance issues. The script needs to first determine each unique process owner on the system, and then for each user ...
1
vote
2answers
906 views

find out the location of where a process was executed

I have a number of ruby processes running: ps -A | grep ruby 3518 ? 00:00:12 ruby 10316 ? 00:00:00 ruby 22400 pts/5 00:00:45 ruby 23332 ? 00:00:07 ruby I get the pid ...
0
votes
1answer
905 views

how to know process pid of bash function running as child?

I am trying to know the pid of a function that was run as child process on a script FUNCtstPsSelf.sh #!/bin/bash echo "pid=$$;ppid=$PPID" ps -p $$ function FUNCtstPsSelf() { sleep 3; echo ...
0
votes
2answers
702 views

bash and c - 2 processes in concurrency to write a file

I made a C program, it forks 2 processes and each one of them uses system() to call 2 scripts (script1.sh and script2.sh), what I want to do is let them write in a file (output.txt) in parallel ...
4
votes
1answer
5k views

Run program from a shell script but behave as one process only?

Is there a way I can execute an application from a shell script but not create another process. I want it to look like one process only. It doesn't matter whether my shell script is replaced by a new ...
17
votes
6answers
15k views

Shell script to -9 kill based on name

Is there a way (perhaps a script) how to automate this process: petr@sova:~$ ps -ef | grep middleman petr 18445 2312 1 12:06 pts/2 00:00:01 /home/petr/.rvm/gems/ruby-1.9.3-p362/bin/middleman ...
0
votes
3answers
1k views

Launch two processes and return first process to the foreground so it can be killed with ctrl-c

I am launching two processes in a bash script: run_webserver xdg-open http://$(hostname)/dev-environment The run_webserver is an ongoing process, so I need to be able to kill it with ...
15
votes
6answers
33k views

How to determine whether a process is running or not and make use it to make a conditional shell script?

How can I determine if a process is running or not and then have a bash script execute some stuff based on that condition... For example: if process 'abc' is running, do this if it is not running , ...
4
votes
1answer
11k views

How do I get the parent process ID of a given child process?

How to get parent pid from a given children pid? I know I can mannully check it under /proc, I am wonder if there is a smart/better way to achieve this in Ubuntu. Note the parent may or may not be ...
3
votes
1answer
354 views

launching a program from bash causes bash to go to new prompt

When I run a program from the console, e.g. me@box:~$ firefox I expect the console to log error messages (I think this is std out or std err?) and other items from the program, firefox in this ...
1
vote
1answer
71 views

How to identify an application executable from ps

If I execute ps -ef | grep java I get the following noaccess 12144 908 0 Apr 28 ? 697:47 /usr/java/bin/java -server -Xmx128m -XX:+UseParallelGC -XX:ParallelGCThreads=4 Though, in ...
41
votes
4answers
54k views

Running programs in the background from terminal

How do I run a program in the background of a shell, with the ability to close the shell while leaving the program running? Lets say my UI is having problems or for some reason, I need to boot up a ...
5
votes
5answers
403 views

How can I add to a already running process an additional 'shutdown' command?

On a regular basis I forget to add && shutdown -h now to a long-running process. Is there any way to add a shutdown -h now command after the first command was invoked? It is not intended to ...
3
votes
2answers
1k views

Shell script to restart a process if it outputs a certain piece of text

I have a python program which, from time to time, crashes with a number of different exceptions usually due to network issues. The only way to get it to work is to restart it. How would I write a ...
6
votes
2answers
3k views

Can I use standard tools to get the full name of a process, when its name has embedded spaces?

I understand that it may be a rare situation for an executable to have spaces in it, but it could happen. An example may be the best explanation.. Using standard tools, I want to determine the ...
11
votes
1answer
12k views

How, in a script, can I determine if a file is currently being written to by another process?

I'm very new to bash scripting, so I might be barking up the wrong tree, but here is my current situation: In a script, I start soffice; to convert an odt to a pdf It seems that soffice detaches ...