mirror of
https://github.com/CISOfy/lynis.git
synced 2025-07-27 15:54:09 +02:00
Merge pull request #1340 from HansHoogerwerf/date-nanosecond-support-check
Verify the linux OS supports nanoseconds
This commit is contained in:
commit
38b7b47c9c
@ -2562,14 +2562,18 @@
|
||||
|
||||
GetTimestamp() {
|
||||
ts=0
|
||||
case "${OS}" in
|
||||
"Linux")
|
||||
# Detect if the implementation of date supports nanoseconds,
|
||||
if [ "${OS}" = "Linux" ]; then
|
||||
current_nanoseconds=$(date "+%N")
|
||||
# Verify if the result of the command is a number
|
||||
if [ -n "$current_nanoseconds" ] && [ "$current_nanoseconds" -eq "$current_nanoseconds" ] 2>/dev/null; then
|
||||
ts=$(date "+%s%N")
|
||||
;;
|
||||
*)
|
||||
else
|
||||
ts=$(date "+%s")
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
else
|
||||
ts=$(date "+%s")
|
||||
fi
|
||||
echo $ts
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user