RabbieBurns Posted January 20, 2010 Posted January 20, 2010 Im looking for a bash script i can run as a cron that will check for the existance of a running process (ps x | grep 2008R2 or something like that) and if its not running, it will run the command to start the virtuualbox. Anyone able to knock something up for me please?
RabbieBurns Posted January 21, 2010 Author Posted January 21, 2010 #!/bin/bash # Script to check if the VM is up and if not, start it. # Check for 2008R2 Virtual Machine if ping -c 1 192.168.2.30 > /dev/null then : # colon is a null and is required else echo "Virtual Machine is down, starting VM" VBoxHeadless -startvm 2008R2 & fi
RabbieBurns Posted January 21, 2010 Author Posted January 21, 2010 Looks fine to me. Cheers, I was just answering my own question in case anyone else was looking for an answer
powdarrmonkey Posted January 21, 2010 Posted January 21, 2010 (edited) You could simplify the test a bit: #!/bin/bash # Script to check if the VM is up and if not, start it. # Check for 2008R2 Virtual Machine ping -c 1 192.168.2.30 > /dev/null || (echo "Virtual Machine is down, starting VM"; VBoxHeadless -startvm 2008R2 & ) edit:I stole your signature test for my own, nice idea! Edited January 21, 2010 by powdarrmonkey
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now