-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcrontab_mk
More file actions
executable file
·38 lines (30 loc) · 1.03 KB
/
crontab_mk
File metadata and controls
executable file
·38 lines (30 loc) · 1.03 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
#!/bin/bash
EXITCODE=0;
# info distro linux
if [[ -f /etc/os-release ]]; then
OS="$(cat /etc/os-release | grep -i "^id=" | sed 's/ID=//' | sed 's/\"//g')";
fi
# crontab dir for distro linux
if [[ $OS == "debian" ]]; then
VAR_CRON_FILES="/var/spool/cron/crontabs/*";
elif [[ $OS == "centos" ]]; then
VAR_CRON_FILES="/var/spool/cron/*";
fi
CRON_FILES="$(find /etc/cron* ${VAR_CRON_FILES} -type f)";
echo "<<<crontab_list>>>";
while read -r CRON_FILE; do
lastModified="$(stat "${CRON_FILE}" | grep "Modify: " | sed -e 's/Modify: //g')"
date="$(echo $lastModified | awk '{print $1}')"
time="$(echo $lastModified | awk '{print $2}')"
tzinfo="CEST"
rows="$(cat "${CRON_FILE}" | grep -v ^\# | grep -v ^$ | grep ^[0-9\*] | wc -l)"
# if [[ ${rows} -gt 0 ]]; then
echo "#${CRON_FILE};${date} ${time::15} ${tzinfo};${rows}"
# fi
while read line; do
if [[ ! -z "${line}" ]]; then
echo "${line}";
fi
done <<<"$(cat "${CRON_FILE}" | grep -v ^\# | grep -v ^$ | grep ^[0-9\*])"
done <<<"${CRON_FILES}"
# | awk 'BEGIN {FS="."}{print $1}'