Recently my tor relay started crashing daily. I found out it was because the usage increased (approaching 10MB/s) and every night when logrotate asked it to reload, it failed with:
[May 30 04:02:01.000 [notice] Received reload signal (hup). Reloading config and resetting internal state. May 30 04:02:01.000 [warn] Could not open "/etc/tor/torrc": Too many open files May 30 04:02:01.000 [warn] Unable to open configuration file "/etc/tor/torrc". May 30 04:02:01.000 [err] Reading config failed--see warnings above. For usage, try -h. May 30 04:02:01.000 [warn] Restart failed (config error?). Exiting. May 30 04:02:01.000 [warn] Couldn't open "/var/lib/tor/state.tmp" (/var/lib/tor/state) for writing: Too many open files
The problems comes from LimitNOFILE=4096 in the service file, and I had no idea how to fix it cleanly.
fcrozat gave me the answer which I'll summarize as:
mkdir /etc/systemd/system/tor.service.d/ echo "[Service]\nLimitNOFILE=16384" > /etc/systemd/system/tor.service.d/limit.conf systemctl daemon-reload service tor restart