Skip to content

Instantly share code, notes, and snippets.

@musha68k
Last active September 27, 2018 16:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save musha68k/15ce06d4f9b9bdaa60d4 to your computer and use it in GitHub Desktop.
Save musha68k/15ce06d4f9b9bdaa60d4 to your computer and use it in GitHub Desktop.
Set system dates for all running vagrant instances like a savage (πŸ”¨πŸ‘ˆ)

How to fix skewed system times on multiple vagrant instances 🍻

Set current date of darwin/osx on all local vagrant instances:

date | pbcopy && vagrant status | grep running | awk '{print $1}' | xargs -I {} vagrant ssh {} -c "sudo date --s \"$(pbpaste)\""

Set current date of darwin/osx on all vagrant instances:

date | pbcopy && vagrant global-status | grep running | awk '{print $1}' | xargs -I {} vagrant ssh {} -c "sudo date --s \"$(pbpaste)\""

The alias I set for myself looks like this:

alias fix_vagrant_dates="date | pbcopy && vagrant global-status | grep -v 'not running' | grep running | grep virtualbox | awk '{print \$1}' | xargs -P 9001 -I {} vagrant ssh {} -c \"sudo date --s \\\"\$(pbpaste)\\\"\" >& /dev/null"

Fake pbcopy/pbpaste via x windows:

alias pbcopy='xsel --clipboard --input'
alias pbpaste='xsel --clipboard --output'

Fake pbcopy/pbpaste via xclip:

alias pbcopy='xclip -selection clipboard'
alias pbpaste='xclip -selection clipboard -o'
@musha68k
Copy link
Author

Max of 10 processes in parallel, without needlessly using pbcopy/pbaste (should work on GNU/Linux like that):

vagrant status | grep running | awk '{print $1}' | xargs -P 10 -I {} vagrant ssh {} -c "sudo date --s \"$(date)\""

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment