Skip to content

Instantly share code, notes, and snippets.

@nonchip
Created December 19, 2015 12:52
Show Gist options
  • Save nonchip/6a5800af8d9128c541e7 to your computer and use it in GitHub Desktop.
Save nonchip/6a5800af8d9128c541e7 to your computer and use it in GitHub Desktop.
/usr/local/bin/once: call a command exactly once per uptime. useful for e.g. startx in .profile
#!/bin/zsh
test -e /dev/shm/once.db || touch /dev/shm/once.db
if grep -q "$*" /dev/shm/once.db
then echo "$* already in oncedb" >&2
else
echo "$*" >> /dev/shm/once.db
"$@"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment