This is redacted version of a powershell script I had to come up with recently to fix an issue with a web application in our environment.

$hostsPath = "$env:windir\System32\drivers\etc\hosts"
$ip = ipconfig | findstr /i IPv4 |Out-string
$ip = $ip.TrimStart("IPv4 Address. . . . . . . . . . . : ")
$ip = $ip.TrimEnd("`n")
$ip = $ip.TrimEnd("`r")
Clear-Content $hostsPath
ipconfig /flushdns
Add-Content $hostsPath "$ip siteurl.com"

I will walk through what is going on here…
(more…)

One of the things that is often handy to know is when a server was last rebooted. This is nice to know for things like patching, registry updates, etc… stuff that requires a reboot to take affect.

I came across a quick article that explains a very quick way to get an answer.

Open up a command prompt and use the following command:

systeminfo | find "Time:"

A few seconds later you will get a response telling you when the last system boot was. Very handy!

References:

http://www.fieldbrook.net/TechTips/Windows/Uptime.asp

I have been having issues I can’t narrow down that have been causing Apache to go into a conniption and the websites on my server to go down. The quick duct tape fix has been to login ot the server and restart Apache. This is a manual process though and the site could be down for a while before I get in to do the restart.

There are tons of website monitoring services out there, some free, that can alert you to such a failure. The “free” ones I have found though don’t allow you to do more frequent checking without upgrading to a paid plan. Furthermore, most are only “alert” services and cannot actually intervene and do anything.

I thought there must be a way to do this via a script and a cron job. After some digging around I wasn’t able to find a simple script that would do exactly what I wanted. However I found enough bits and pieces to cobble this together and after some testing it seems to work well. (more…)

If you haven’t gotten around to setting up regular backups of your website MySQL databases you are asking for serious trouble. In this article I am going to provide shell script examples that you can use to quickly setup database backup jobs. As far as scope goes, we are going to be talking about how to perform a backup to a local directory, compress that backup file, and then port it off to a remote location if you so desire. The following method has worked really well for me and I hope it does for you as well.
(more…)