Skip to content

Instantly share code, notes, and snippets.

@ravikant-pal
Last active July 13, 2025 12:33
Show Gist options
  • Save ravikant-pal/5337be01d2e660c9b7eb23338ba22f9d to your computer and use it in GitHub Desktop.
Save ravikant-pal/5337be01d2e660c9b7eb23338ba22f9d to your computer and use it in GitHub Desktop.
Create Sample Logs
#!/bin/sh
mkdir -p logs
cat > logs/service1.log << EOF
2025-07-13 12:00:00 INFO Starting service
2025-07-13 12:01:15 INFO Checking database connection
2025-07-13 12:02:30 WARN Connection slow, retrying
2025-07-13 12:05:00 ERROR Failed to connect to DB
2025-07-13 12:06:00 INFO Retrying connection
2025-07-13 12:10:00 INFO Connection established
2025-07-13 12:15:00 INFO Service started successfully
EOF
cat > logs/service2.log << EOF
2025-07-13 12:00:00 INFO User login success: user123
2025-07-13 12:05:10 INFO User logout: user123
2025-07-13 12:07:20 WARN Password attempt failed: user456
2025-07-13 12:15:00 WARN Disk space low: 5% remaining
2025-07-13 12:20:00 INFO User login success: user789
2025-07-13 12:25:00 INFO User login success: user456
EOF
cat > logs/service3.log << EOF
2025-07-13 12:30:00 INFO Scheduled job started
2025-07-13 12:32:00 INFO Processing data batch #42
2025-07-13 12:35:00 ERROR Job failed due to timeout
2025-07-13 12:40:00 INFO Job retry initiated
2025-07-13 12:45:00 INFO Job completed successfully
EOF
echo "Sample log files with entries created in the 'logs/' directory."

Give the permission

chmod +x create_sample_logs.sh

Execute the file

./create_sample_logs.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment