SUPPORT THE SITE WITH A CLICK

Subscribe Rss:

SUPPORT THE SITE WITH A CLICK

Monday, December 22, 2008

Cronjob on Linux/Apache

Using cronjob i have written a script to make my apache webserver keep on running even if it stops.First start learning crontab options,as i am a ruby developer,i have written the script in ruby.

Ruby script for checking the apache process



#!/usr/bin/ruby -w
require 'etc'
s= `netstat -ntlp|grep apache2`
if s==""
`/etc/init.d/apache2 start`
Tan=File.open('/home/gen/logs/info','a')
Tan.puts "Apache server started at " + Time.now.to_s + " with " + ` /sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'`+ "with user login as "+ Etc.getlogin
Tan.close
end


This script i will be working fine for unix users.

CronJob script for every 1 minutes



# m h dom mon dow command
*1/ * * * * ruby /home/gen/JSwing/ruby/cron.rb

No comments :

Post a Comment