Repository navigation
Expand file tree
/
Copy pathgenerate_scripts.sh
More file actions
76 lines (58 loc) · 1.8 KB
/
Copy pathgenerate_scripts.sh
File metadata and controls
76 lines (58 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# #!/bin/bash
# # Define the list of scripts you want to create
# scripts=(
# "22_math_ops.sh"
# "23_returns_and_status.sh"
# "24_system_monitors.sh"
# "25_user_mgmt.sh"
# "26_logger_utils.sh"
# "27_health_check.sh"
# "28_retry_mechanism.sh"
# "29_deploy_rollback.sh"
# "30_container_k8s_val.sh"
# "31_file_crud.sh"
# "32_file_read_write.sh"
# "33_text_stats.sh"
# "34_search_replace.sh"
# "35_file_discovery.sh"
# "36_backup_maintenance.sh"
# )
# echo "🚀 Starting script generation..."
# echo "----------------------------------------"
# # Loop through each script name in the array
# for script in "${scripts[@]}"; do
# # 1. Create the file using touch
# touch "$script"
# # 2. Add the shebang and the comment block using a heredoc
# cat << EOF > "$script"
# #!/bin/bash
# <<comment
# comment
# # Your code starts here
# EOF
# # 3. Make the script executable
# chmod +x "$script"
# echo "✅ Created and configured: $script"
# done
# echo "----------------------------------------"
# echo "🎉 All scripts generated successfully and made executable!"
#!/bin/bash
set -euo pipefail
# Directory to store the log files
LOG_DIR="var/log/logs"
mkdir -p "$LOG_DIR"
# Loop from 8 days ago to today (0 = today, 8 = 8 days ago)
for i in $(seq 15 -1 0); do
# Calculate the date for this iteration
log_date=$(date -d "-$i days" +%Y-%m-%d)
# Filename based on that date
filename="$LOG_DIR/app-${log_date}.log"
# Create the file with some sample content
echo "Log entry for $log_date" > "$filename"
# Set both modification and access time to that date (midnight)
touch -d "$log_date" "$filename"
echo "Created: $filename (dated $log_date)"
done
echo ""
echo "Done. Files created:"
ls -la "$LOG_DIR"