- Added documentation via mdbook - Created basic VS code extension - Implemented if else blocks and changed some syntax - fixed some issues
1.3 KiB
1.3 KiB
System Maintenance
⚠️ This documentation is AI-generated and may contain errors.
Example system maintenance script demonstrating permission checks, environment variables, and log rotation.
Script
See the full script in /examples/system_maintenance.rsh in the repository.
#!/usr/bin/env rush
HOSTNAME = "prod-server-01"
MAX_DISK_USAGE = "85"
LOG_DIR = "/var/log"
BACKUP_DIR = "$HOME/backups"
echo "System Maintenance Script"
echo "Running on: $HOSTNAME"
echo "User: $USER"
# Permission-aware execution
if $IS_ROOT {
echo "Running with root privileges"
for check in disk memory services {
echo "Checking $check status..."
if $check {
echo " ✓ $check is healthy"
}
}
} else {
echo "Running as $USER (limited permissions)"
echo "Some checks may be skipped"
}
# Log rotation planning
echo "Preparing log rotation in $LOG_DIR"
for days in 1 7 30 {
LOG_ARCHIVE = "$BACKUP_DIR/logs-$days-days-old.tar.gz"
echo "Would archive logs older than $days days to $LOG_ARCHIVE"
}
Key Concepts
- Permission-aware execution: Different behavior for root vs normal user
- String interpolation: Building paths with
$HOME,$USER - Loops for maintenance tasks: Iterating over checks and retention periods