0

I want to script check port: the first check port open or close If port close.after check PID for service on port.If exist PID, kill PID, restart service have message on file log.

4
  • What have you tried thus far, what do you mean by "check port" ? If the port is closed how can you get the services PID? If you provide a more precise question, I can probably help you - conceptually what you are trying to do can be done with tools like "logger" for logging, netcat to check if a port is open or fuser to check the process ID associated with a port, but its hard to put these together without knowing the service, as it appears you are asking to "test for a negative", and thus you can't get some information you need from the negative result and need to look elsewhere for it.
    – davidgo
    Sep 11, 2013 at 5:59
  • i think Port close but PID can exist because service hang.:D
    – Gato
    Sep 11, 2013 at 6:38
  • Surely the solution would be to check if the service is working (if its TCP you could use nc (netcat), and then if its not working send a command to "killall" the process ?
    – davidgo
    Sep 11, 2013 at 8:26
  • i was find tutorial in bash.cyberciti.biz/monitoring/… but not check PID and kill service.
    – Gato
    Sep 11, 2013 at 9:14

0

You must log in to answer this question.

Browse other questions tagged .