Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
    
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 '13 at 5:59
    
i think Port close but PID can exist because service hang.:D –  Gato Sep 11 '13 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 '13 at 8:26
    
i was find tutorial in bash.cyberciti.biz/monitoring/… but not check PID and kill service. –  Gato Sep 11 '13 at 9:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.