Manually Rotating an Aerospike Log File
Log rotation is managed by systemd-journald
, and in normal operations you don't have to pay attention to it. However, there are some use cases for manual file rotation, such as:
- Free up storage space.
- Separate debugging logs.
- Move log files to a different location.
Follow these steps to manually rotate the log file. The following steps use /var/log/aerospike/aerospike.log
for the example log file.
Move the existing log file to a new location, which is anywhere you want:
mv /var/log/aerospike/aerospike.log /var/log/aerospike/aerospike-old.log
Find the
asd
(Aerospike daemon) process ID. In systemd environments use thepidof
command:pidof asd
The expected output is a process number, for example:
3513
In non-systemd environments read its pidfile:
cat /var/run/aerospike/asd.pid
Send a SIGHUP to the
asd
process:kill -s SIGHUP 3513
The following message is printed at the end of the old log file:
SIGHUP received, rolling log
Aerospike re-creates the original log file, and only new messages appear in it.
Finding the log ID and log file location
Use asinfo
to find the log IDs and log file locations:
asinfo -v "logs" -l
Expected output:
0:/var/log/aerospike/aerospike.log
1:stderr
The example output shows that there is a log file at /var/log/aerospike/aerospike.log
, and a second logging stream directed to stderr. See Configuring Log Files for more information.