-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
docs/learning/solutions/storage-management/storage-log-rotation.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Log Rotation and Cleanup | ||
|
||
This documentation provides details on how to use a Rundeck job to manually rotate, compress, and clean up log files in a specified directory. This job is useful for managing log files to prevent them from consuming excessive disk space. | ||
|
||
::: note | ||
This is just one example of how to implement a log rotation job. Other opportunities exist leveraging `logrotate` or other methods. | ||
::: | ||
|
||
## Job Description | ||
|
||
This job will: | ||
- Rotate log files by renaming them with a timestamp. | ||
- Compress the rotated log files to save disk space. | ||
- Delete old log files that exceed a specified retention period. | ||
|
||
### Assumptions | ||
|
||
- The job assumes the node is a Linux endpoint with `bash` and `gzip` installed. | ||
- The default log directory is `/var/log/myapp`, and should be customized. | ||
|
||
### Notes | ||
|
||
- No nodes are selected by default. Change Target Nodes and select the endpoint to run against. If multiple nodes are selected the same script will be run on each node. | ||
|
||
## Configuration | ||
|
||
### Job Options | ||
|
||
- **Log Directory:** The path where the log files are located. The default is `/var/log/myapp`. | ||
- **Retention Days:** The number of days to retain old log files. The default is `30` days. | ||
|
||
![job-options](/assets/img/log-rotation-job-options.png)<br> | ||
|
||
## Successful Execution | ||
|
||
Upon successful execution, the job will: | ||
- Rename current log files by appending a timestamp. | ||
- Compress the renamed log files. | ||
- Remove compressed log files older than the specified retention period. | ||
|
||
![success-output](/assets/img/log-rotation-success-output.png)<br> | ||
|
||
## Troubleshooting | ||
|
||
- **Log Rotation Issues**: Ensure the log directory and file permissions are correctly set. | ||
- **Compression Issues**: Verify that `gzip` is installed and accessible on the system. | ||
- **Cleanup Issues**: Check the retention period and ensure the `find` command syntax is correct. | ||
|
||
## Conclusion | ||
|
||
This custom log rotation and cleanup job helps manage log files efficiently by rotating, compressing, and deleting old logs. Adjust the script and configuration parameters as needed to fit your specific requirements. |