-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_journalctl.sh
40 lines (36 loc) · 1.12 KB
/
run_journalctl.sh
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
#!/bin/bash
# Function to execute journalctl for all logs
execute_journalctl_all() {
journalctl _UID=$(id -u $1)
}
# Function to execute journalctl for logs with "error"
execute_journalctl_error() {
journalctl _UID=$(id -u $1) | grep "error"
}
# Display the menu options
echo "Menu:"
echo "1. Execute journalctl for all logs"
echo "2. Execute journalctl for logs with 'error'"
echo "3. Execute journalctl for multiple usernames"
read -p "Please enter your choice (1, 2, or 3): " choice
case $choice in
1)
read -p "Please enter the username: " username
execute_journalctl_all $username
;;
2)
read -p "Please enter the username: " username
execute_journalctl_error $username
;;
3)
read -p "Please enter the list of usernames separated by spaces: " usernames
for user in $usernames; do
echo "Journalctl output for user $user:"
execute_journalctl_all $user
echo "-------------------------------------------------"
done
;;
*)
echo "Invalid choice. Please enter either 1, 2, or 3."
;;
esac