Souvik
Souvik

Reputation: 1269

Restart Unix service

I have Ubuntu in my machine where I have installed snmpd. To start stop I use below command:

  1. service snmpd start
  2. service snmpd stop

Now I have to execute this comments from java. I have tried with but it does not work.

Runtime.getRuntime.exe("service snmpd start")

So, could you tell me how to execute a service of Linux suse through java?

Any help would be great

Upvotes: 0

Views: 315

Answers (1)

Souvik
Souvik

Reputation: 1269

Suddenly people started talking about a link instead of the question. The solution is easy. One need to wait for the process to complete. See below code.

Process process = Runtime.getRuntime().exec("service snmpd start");
process.waitFor();

Upvotes: 1

Related Questions