forked from colin/swap-increase
42 lines
1.5 KiB
Markdown
42 lines
1.5 KiB
Markdown
# 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
|
|
|
|
To use this script, you can execute it directly from the URL without downloading it.
|
|
|
|
### Execute Directly from URL
|
|
|
|
Run the script directly from the URL using `curl` and piping to `bash`:
|
|
|
|
```bash
|
|
curl -sSL https://git.nixc.us/colin/pull-logs/raw/branch/main/pull-logs.sh | bash -s -- <start-date> <start-time> <end-date> <end-time>
|
|
```
|
|
|
|
### Example
|
|
|
|
To pull logs between `2024-09-26 08:00:00` and `2024-09-26 12:00:00`, use:
|
|
|
|
```bash
|
|
curl -sSL https://git.nixc.us/colin/pull-logs/raw/branch/main/pull-logs.sh | bash -s -- 2024-09-26 08:00:00 2024-09-26 12:00:00
|
|
```
|
|
|
|
## Output
|
|
|
|
The script will provide the following output:
|
|
|
|
- The range of the logs retrieved.
|
|
- The location where the logs are saved (in `/tmp` with a filename indicating the time range).
|
|
- A message indicating if `journalctl` is not available on the system.
|
|
|
|
## Note
|
|
|
|
This script assumes the logs are managed by `journalctl`. It may require `sudo` privileges to access certain system logs. Ensure you have appropriate permissions to execute the script. |