From 8772657eafe9541d7879b65ff3750903f200cb25 Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Fri, 5 Jun 2020 17:44:41 +0200 Subject: [PATCH] Do not depend on /proc for calculating runtime For example when running grml-live inside a docker environment, /proc doesn't necessarily exist. Instead use seconds since the epoch as base for calculating runtime. Development time sponsored by Sipwise GmbH --- grml-live | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/grml-live b/grml-live index ce6cb35..7dc20f8 100755 --- a/grml-live +++ b/grml-live @@ -579,7 +579,8 @@ if [ -n "$CONFIG" ] ; then fi fi -start_seconds=$(cut -d . -f 1 /proc/uptime) +SECONDS=unknown +start_seconds="$(date +%s)" log "------------------------------------------------------------------------------" log "Starting grml-live [${GRML_LIVE_VERSION}] run on $(date)" log "Using local config file: $LOCAL_CONFIG" @@ -1692,7 +1693,10 @@ fi # }}} # finalize {{{ -[ -n "$start_seconds" ] && SECONDS="$[$(cut -d . -f 1 /proc/uptime)-$start_seconds]" || SECONDS="unknown" +if [ -n "${start_seconds}" ] ; then + end_seconds="$(date +%s)" + SECONDS="$(( end_seconds - start_seconds ))" +fi log "Successfully finished execution of $PN [$(date) - running ${SECONDS} seconds]" dpkg_to_db # make sure we catch the last log line as well, therefore execute between log + einfo -- 2.1.4