According to https://unix.stackexchange.com/a/478636/674, cron modifies the execution environment to execute a job.
When I run
sudo service tor reloadtwice directly in bash, it always shows two different IP addresses$ sudo service tor reload; torsocks curl ipinfo.io/ip; sudo service tor reload; torsocks curl ipinfo.io/ip 12.345.678.901 987.654.321.00Is it correct that
sudo service tor reloadwill most likely change tor exit node, and thus change the public IP address?But when I create a cron job in
/etc/cron.d/myjob,* * * * * tim (sudo service tor reload; torsocks curl ipinfo.io/ip; sudo service tor reload; torsocks curl ipinfo.io/ip) > /tmp/cron.logevery time I check
/tmp/cron.log, it always shows two identical IP addresses, although the IP address changes from job to job (when the next scheduled job overwrites the log, it will show two identical IP addresses not identical to the two before overwriting). Same when I insertsleep 20between the two reload:* * * * * tim (sudo service tor reload; torsocks curl ipinfo.io/ip; sleep 20; sudo service tor reload; torsocks curl ipinfo.io/ip) > /tmp/cron.logAs a cron job, why does
sudo service tor reloadfail to change the IP address? How can I make it work?
Thanks.