0
votes
1answer
355 views

sh bash script ambiguous redirect pid of file using single quotes

I have the following new line in my .sh file su --session-command='$javaCommandLine & >>$serviceLogFile 2>&1 & echo \$! >$pidFile' $serviceUser || return 1 When I had it ...
1
vote
2answers
84 views

If I know the PID number of a process can I know its name?

If I have the PID number for a process (on a UNIX machine), how can I know the name of its associated process? What do I have to do?
0
votes
1answer
62 views

Interfacing strace with Process Name instead of PID

How do I implement a wrapper script pstrace in bash that changees the interface of [sudo] strace -c -p [PID] to [sudo] pstrace -c -p [PROCESS-NAME] similar to how killall [PROCESS-NAME] is ...
1
vote
1answer
337 views

Can I recover a nano process from a previous terminal?

My system crashed while I was in a nano session with unsaved changes. When I log back in via SSH I see the nano process still running when I do a ps. davidparks21@devdb1:/opt/frugg_batch$ ps -ef | ...
3
votes
1answer
944 views

How to get the PID of a process started by /bin/su -c

I'm writing a init.d-script for an java-app. But the java-app should be run by another user. (The OS I'm using is Debian Squeeze.) I already got this: /bin/su - $USER - c "cd $PATH;echo $PASSWORD | ...
5
votes
4answers
3k views

What's a proper way of checking if a PID is running?

I have a .pid file, and I need to check if the process is running. So far I found two options kill -0 `cat something.pid` which prints out an error if the pid isn't running. I know this can be ...
0
votes
1answer
361 views

PID of a command executed in bash

I need a linux / unix command that will execute another command and write the PID of the command it executes to a file... is there such a command? I am not looking for any scheme that puts processes ...
0
votes
1answer
231 views

Shell script Process PID logging and maintenance using exec

I am trying to launch a java process as a server and then might periodically need to restart/kill it at certain times. Since I use a shell script to launch java jvm(to build classpath), I thought of ...
6
votes
5answers
18k views

Bash child proccess PID - how do you get it?

Can any one tell me how to get the PID of a command executed in bash. E.g. I have a bash script that runs imapsync. When the script is killed the imapsync process does not always get killed, so I'd ...
4
votes
5answers
13k views

How to get pid of just started process

I want to start process (eg. myCommand) and get its pid (to allow to kill it later). I tried ps and filter by name, but I can not distinguish process by names myCommand ps ux | awk ...