docs: log into a separate logfile when run as a service in linux (#72)

This commit is contained in:
Slava 2025-03-31 13:14:35 +03:00 committed by GitHub
parent 9b03f04c05
commit fab7f3900e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -428,6 +428,7 @@ We can run Codex as a service via [systemd](https://systemd.io) using following
3. Create directories 3. Create directories
```shell ```shell
sudo mkdir -p /opt/codex/data sudo mkdir -p /opt/codex/data
sudo mkdir -p /opt/codex/logs
``` ```
4. Create a configuration file 4. Create a configuration file
@ -481,6 +482,8 @@ We can run Codex as a service via [systemd](https://systemd.io) using following
ExecStart=/usr/local/bin/codex --config-file="/opt/codex/codex.conf" ExecStart=/usr/local/bin/codex --config-file="/opt/codex/codex.conf"
Restart=always Restart=always
RestartSec=3 RestartSec=3
StandardOutput=append:/opt/codex/logs/codex.log
StandardError=append:/opt/codex/logs/codex.log
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target
@ -498,11 +501,26 @@ We can run Codex as a service via [systemd](https://systemd.io) using following
sudo systemctl status codex sudo systemctl status codex
``` ```
9. Check the logs 9. Enable logs rotation using logrotate
```shell ```shell
sudo journalctl -u codex -S "5min ago" sudo vi /etc/logrotate.d/codex
sudo journalctl -f -u codex ```
sudo tail -f /var/log/syslog | grep codex ```logrotate
/opt/codex/logs/*.log {
daily
missingok
rotate 5
copytruncate
nocreate
nomail
dateext
dateyesterday
}
```
1. Check the logs
```shell
tail -f /opt/codex/logs/codex.log
``` ```
### Run as a service in Windows ### Run as a service in Windows