Created
June 27, 2013 12:23
-
-
Save AlD/5876014 to your computer and use it in GitHub Desktop.
when you have no atd, this is handy
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 | |
# Basic bash implementation of at(1). Obviously doesn't survive a reboot. | |
poor_mans_at() { | |
delay=$[$(date +%s -d "$*") - $(date +%s)] | |
if [[ ! "$delay" -ge 0 ]]; then | |
echo "error: invalid time specification" >&2 | |
return 1 | |
fi | |
mapfile cmds | |
( sleep $delay && eval "${cmds[@]}" )&disown | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment