Automating bash task

function sleep_until {
seconds=$(( $(date -d “$” +%s) – $(date +%s) ))
echo “Sleeping for $seconds seconds”
sleep $seconds
}


Usage:
sleep_until 8:24
Sleeping for 35 seconds
sleep_until ’23:00′
Sleeping for 52489 seconds
sleep_until ‘tomorrow 1:00’
Sleeping for 59682 seconds

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s