I need to start any application using java and get their pid and then using pid kill them using java code or php code in Linux env
Asked
Active
Viewed 71 times
-2
-
what your asking has many different answers, you could elaborate more on this. CRON would be an option on linux machines – some_groceries Nov 30 '15 at 06:41
-
for a simple solution in java have a look [here](http://stackoverflow.com/questions/3403226/how-to-run-linux-commands-in-java-code) at Runtime.getRuntime().exec(). You can run all commands you want and get their output. so start your application. find the pid using ps and kill it. – ArcticLord Nov 30 '15 at 06:44
-
1you can use `shell_exec('your shell command')`, and it will return the complete output as a string.. – check Nov 30 '15 at 06:49
-
my need is 1 start external application like Firefox. 2 getting pid of firefox . 3 and then kill process using pid . – Nishad Brijesh Dec 01 '15 at 10:06
1 Answers
0
I don´t know how to do exactly that, but you can use ProcessBuilder (Java) to do something similar. (You can start and stop the process any time you want with this)

Mayuso
- 1,291
- 4
- 19
- 41
-
using ProcessBuilder (Java) start external application but i don't know how to get start process pid and how to stop that . – Nishad Brijesh Dec 01 '15 at 10:05