tinyproxy / tinyproxy

tinyproxy - a light-weight HTTP/HTTPS proxy daemon for POSIX operating systems
GNU General Public License v2.0
4.67k stars 645 forks source link

Checking `tinyproxy` status and finding its port programmatically #521

Open babaric-dev opened 7 months ago

babaric-dev commented 7 months ago

I'm working on an automation script involving tinyproxy on multiple deployed machines. In my script, I need to check if tinyproxy is already running and find out the port it's using. If not, start an instance and return the port. However, there's a potential issue: users may have customized their tinyproxy configurations, which could interfere with my automation.

I would appreciate guidance on how to determine if tinyproxy is running and find out the port tinyproxy is using because I cannot find a reliable way to do so. Thanks in advance.

rofl0r commented 7 months ago

netstat -tnlp | grep tinyproxy

babaric-dev commented 7 months ago

This command doesn't work when I am a normal user.

rmudingay commented 3 months ago

Not sure if you managed to solve this. If not, maybe this solves your issue. The following commands work without the need for elevated privileges

displays tinyproxy port ps aux | grep tinyproxy | grep -v grep | awk '{ print $2 }'

verify that the port is used by tinyproxy ps -p `ps aux | grep tinyproxy | grep -v grep | awk '{ print $2 }'` -o comm=

rofl0r commented 3 months ago

the second column of ps aux prints process id, not port, at least on my implementation.