#!/bin/bash
tag=$(awk -F, 'NR==1{print $1}' /tmp/time.txt)# output: 17:00
sub_time=$(date -d"${tag} +1:00" +'%H:%M')output: 16:00
current_time=$(date |awk 'NR==1{print $4}' output: 05:51:16
if [[ "$sub_time" -ge "$current_time" ]];then
crontab <<EOF
*/15 * * * * bash server_shutdown.sh
EOF
fi
I want to compare the "current_time" in the current system to the VM shutdown tag from VM with "sub_time" through the if condition.
awk
to filter output ofdate
instead of usingdate
s format string? What does not work (any errors)? Obviously-ge
can only compare integers ... but you should still add this to the question.