-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcron-heartbeat
More file actions
executable file
·67 lines (56 loc) · 878 Bytes
/
cron-heartbeat
File metadata and controls
executable file
·67 lines (56 loc) · 878 Bytes
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
#!/bin/bash
#
# cron-heartbeat
#
[ -n "$MYDIR" ] || {
declare MYDIR=
MYDIR="$(dirname "$(readlink -f "$0")")"
}
declare usagestr="$(
cat <<EOF
$(basename "$0")
\0
EOF
)"
#** usage: print info and instructions to screen
#
# Global
# usagestr
#*
usage() {
echo -e "$usagestr"
}
#** control_c: control-c trap
#
# Global
# CTLC_EXIT - bash environment variable
#*
control_c() {
echo -e "\nCtrl-c detected\nCleaning up and exiting."
exit $CTLC_EXIT
}
#** exitme
#
# Arguments
# $1 - exit code
# $2 - optional message
#*
exitme() {
local -i code="$1"
local msg="$2"
((code == 0)) && exit "$code"
echo -e "$msg"
usage
exit "$code"
}
#** main
#*
main() {
# Trap for control-c
trap control_c SIGINT
LOG="/work/cron-heartbeat.log"
TIMESTAMP="$(date '+%Y-%m-%d %H:%M:%S')"
echo "Cron heartbeat at $TIMESTAMP" >> "$LOG"
exitme 0
}
main "$@"