A script to kill the process and run it again
by Jason.nix from LinuxQuestions.org on (#6PZ5C)
Hello,
I wrote a crontab as follows:
Code:0 1 * * * root /usr/bin/sh /etc/Tor.shThe content of the Tor.sh file is as follows:
Code:#!/bin/sh
PID=$(pgrep -f 'tor -f /etc/tor/OpenVPN')
kill $PID
tor -f /etc/tor/OpenVPNWhen the script is run, the following error is generated:
Code:Aug 14 01:00:01.737 [notice] Tor 0.4.7.16 running on Linux with Libevent 2.1.12-stable, OpenSSL 3.0.13, Zlib 1.2.13, Liblzma 5.4.1, Libzstd 1.5.4 and Glibc 2.36 as libc.
Aug 14 01:00:01.738 [notice] Tor can't help you if you use it wrong! Learn how to be safe at https://support.torproject.org/faq/staying-anonymous/
Aug 14 01:00:01.738 [notice] Read configuration file "/etc/tor/OpenVPN".
Aug 14 01:00:01.741 [notice] You configured a non-loopback address '10.10.0.1:53530' for DNSPort. This allows everybody on your local network to use your machine as a proxy. Make sure this is what you wanted.
Aug 14 01:00:01.741 [notice] You configured a non-loopback address '10.10.0.1:9040' for TransPort. This allows everybody on your local network to use your machine as a proxy. Make sure this is what you wanted.
Aug 14 01:00:01.747 [notice] You configured a non-loopback address '10.10.0.1:53530' for DNSPort. This allows everybody on your local network to use your machine as a proxy. Make sure this is what you wanted.
Aug 14 01:00:01.747 [notice] You configured a non-loopback address '10.10.0.1:9040' for TransPort. This allows everybody on your local network to use your machine as a proxy. Make sure this is what you wanted.
Aug 14 01:00:01.748 [notice] Opening Socks listener on 127.0.0.1:9050
Aug 14 01:00:01.748 [warn] Could not bind to 127.0.0.1:9050: Address already in use. Is Tor already running?
Aug 14 01:00:01.748 [notice] Opening DNS listener on 10.10.0.1:53530
Aug 14 01:00:01.748 [notice] Opened DNS listener connection (ready) on 10.10.0.1:53530
Aug 14 01:00:01.748 [notice] Opening Transparent pf/netfilter listener on 10.10.0.1:9040
Aug 14 01:00:01.748 [warn] Could not bind to 10.10.0.1:9040: Address already in use. Is Tor already running?
Aug 14 01:00:01.748 [notice] Closing partially-constructed DNS listener connection (ready) on 10.10.0.1:53530
Aug 14 01:00:01.748 [warn] Failed to parse/validate config: Failed to bind one of the listener ports.
Aug 14 01:00:01.748 [err] Reading config failed--see warnings above.As if the previous process was not killed. Where's the problem?
Thank you.
I wrote a crontab as follows:
Code:0 1 * * * root /usr/bin/sh /etc/Tor.shThe content of the Tor.sh file is as follows:
Code:#!/bin/sh
PID=$(pgrep -f 'tor -f /etc/tor/OpenVPN')
kill $PID
tor -f /etc/tor/OpenVPNWhen the script is run, the following error is generated:
Code:Aug 14 01:00:01.737 [notice] Tor 0.4.7.16 running on Linux with Libevent 2.1.12-stable, OpenSSL 3.0.13, Zlib 1.2.13, Liblzma 5.4.1, Libzstd 1.5.4 and Glibc 2.36 as libc.
Aug 14 01:00:01.738 [notice] Tor can't help you if you use it wrong! Learn how to be safe at https://support.torproject.org/faq/staying-anonymous/
Aug 14 01:00:01.738 [notice] Read configuration file "/etc/tor/OpenVPN".
Aug 14 01:00:01.741 [notice] You configured a non-loopback address '10.10.0.1:53530' for DNSPort. This allows everybody on your local network to use your machine as a proxy. Make sure this is what you wanted.
Aug 14 01:00:01.741 [notice] You configured a non-loopback address '10.10.0.1:9040' for TransPort. This allows everybody on your local network to use your machine as a proxy. Make sure this is what you wanted.
Aug 14 01:00:01.747 [notice] You configured a non-loopback address '10.10.0.1:53530' for DNSPort. This allows everybody on your local network to use your machine as a proxy. Make sure this is what you wanted.
Aug 14 01:00:01.747 [notice] You configured a non-loopback address '10.10.0.1:9040' for TransPort. This allows everybody on your local network to use your machine as a proxy. Make sure this is what you wanted.
Aug 14 01:00:01.748 [notice] Opening Socks listener on 127.0.0.1:9050
Aug 14 01:00:01.748 [warn] Could not bind to 127.0.0.1:9050: Address already in use. Is Tor already running?
Aug 14 01:00:01.748 [notice] Opening DNS listener on 10.10.0.1:53530
Aug 14 01:00:01.748 [notice] Opened DNS listener connection (ready) on 10.10.0.1:53530
Aug 14 01:00:01.748 [notice] Opening Transparent pf/netfilter listener on 10.10.0.1:9040
Aug 14 01:00:01.748 [warn] Could not bind to 10.10.0.1:9040: Address already in use. Is Tor already running?
Aug 14 01:00:01.748 [notice] Closing partially-constructed DNS listener connection (ready) on 10.10.0.1:53530
Aug 14 01:00:01.748 [warn] Failed to parse/validate config: Failed to bind one of the listener ports.
Aug 14 01:00:01.748 [err] Reading config failed--see warnings above.As if the previous process was not killed. Where's the problem?
Thank you.