Make sure to change USERNAME below, as well as any paths that may be different in your case.
#!/usr/local/bin/ruby #Modified from Julik's original code posted to TextDrive forums. pstab = `ps axww` def kill_fcgi_proc(line) its = line.strip.split(/\s+/) pid = its[0] puts "KILLING #{line}" `kill -9 #{pid}` sleep(3) end if pstab =~ /\/usr\/local\/sbin\/lighttpd -f/ puts "Lighttpd still running." else pstab.scan(/^.*dispatch\.fcgi\s*$/) do |line| kill_fcgi_proc line end pstab = `ps axww` if pstab =~ /dispatch\.fcgi/ puts "Error, rogue dispatch.fcgi's still pissing jason off." else puts "Rogue dispatch.fcgi's cleared, starting lighty!" `/usr/local/sbin/lighttpd -f /home/USERNAME/lighttpd/lighttpd.conf` end end