# 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 ```bash 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: 1. Collect logs from `journalctl` within the 5-minute range before and after the specified target time (Saturday, September 28, 2024, at 11:35 am). 2. Search through relevant files in `/var/log/` (such as `syslog`, `auth.log`, and `kern.log`). 3. Check for logs from specific services (e.g., `nginx`, `apache2`, `mysql`). 4. Print all logs to `stdout` for easy piping into a file. You can pipe the output to a file: ```bash 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.