Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

@musha68k musha68k commented Feb 12, 2016

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