forked from colin/swap-increase
|
||
---|---|---|
README.md | ||
pull-logs.sh |
README.md
Log Retrieval Script
This script allows you to retrieve logs from a server based on a specified date and time range. It uses journalctl
to extract logs within the provided time window, saving them to a file for easy access.
Features
- Retrieves logs using
journalctl
from the specified start and end date/time. - Automatically saves the logs to a file for future reference.
- Ensures logs are only retrieved within the given time frame.
- Checks if
journalctl
is available on the system before execution.
Usage
curl -sSL https://git.nixc.us/colin/pull-logs/raw/branch/main/pull-logs.sh | bash -s -- 2024-09-28 11:35 5
Output
This script will:
- Collect logs from
journalctl
within the 5-minute range before and after the specified target time (Saturday, September 28, 2024, at 11:35 am). - Search through relevant files in
/var/log/
(such assyslog
,auth.log
, andkern.log
). - Check for logs from specific services (e.g.,
nginx
,apache2
,mysql
). - Print all logs to
stdout
for easy piping into a file.
You can pipe the output to a file:
curl -sSL https://git.nixc.us/colin/pull-logs/raw/branch/main/pull-logs.sh | bash -s -- 2024-09-28 11:35 5 > logs_output.txt
Notes
- The script assumes all logs follow a standard timestamp pattern and will adjust based on the service if necessary.
- If additional service logs are required, you can extend the
service_logs
array with the path to those log files.