Skip to content

Instantly share code, notes, and snippets.

@AlD
Created June 27, 2013 12:23
Show Gist options
  • Save AlD/5876014 to your computer and use it in GitHub Desktop.
Save AlD/5876014 to your computer and use it in GitHub Desktop.
when you have no atd, this is handy
#!/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