#!/bin/bash
# Write to Log File.
sed -i "/# Program Sync Log/a \ $(date +'%F %T') Program AutoSync starting..." /home/tony/Desktop/Sync-Log
# Open Program noGui.
killall java
cd /home/tony/Desktop/Program
java -jar Program.jar -noGui
# Write to Log File
sed -i "/# Program Sync Log/a \ $(date +'%F %T') Program AutoSync complete!" /home/tony/Desktop/Sync-Log
My log file contains the start and finish time. I would like to add a total runtime to this log file sot hat it reads something like "Total Run Time = 25 min, 30 sec."
How do I do this?
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason:Topic automatically closed 6 months after creation. New replies are no longer allowed.
There's a special variable called $SECONDS which begins incrementing every second from script execution; you can use that, then use basic maths to choose how you want the user informed. If you need the variable to increment after a certain point, reassign it to 0 at the desired point.