Last active
March 19, 2021 12:56
-
-
Save deven96/693a80120c2680676f9bd00aa5fe1380 to your computer and use it in GitHub Desktop.
Run command only if in work period
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# run function passed to this if we are in work period | |
# e.g runIfWorkPeriod echo "Hello there" will only | |
# output "Hello there" if currenttime is within work period | |
function runIfWorkPeriod { | |
start_time="09:00" | |
end_time="17:00" | |
currenttime=$(date +%H:%M) | |
if [[ "$currenttime" > "$start_time" ]] && [[ "$currenttime" < "$end_time" ]]; then | |
"$@" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment