Skip to content

Instantly share code, notes, and snippets.

@deven96
Last active March 19, 2021 12:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deven96/693a80120c2680676f9bd00aa5fe1380 to your computer and use it in GitHub Desktop.
Save deven96/693a80120c2680676f9bd00aa5fe1380 to your computer and use it in GitHub Desktop.
Run command only if in work period
#!/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