Page 1 of 1

Use cron to check if server error alive?

PostPosted: Sat Nov 22, 2014 5:35 am
by paros
Is it posible to use cron scheduler to check if a specific Web server is alive and running?

Re: Use cron to check if server error alive?

PostPosted: Sat Nov 22, 2014 9:05 am
by Jocko
hi Paros,

Yes, you should be able to do it.

If no pid file exist with your server, you can use the ps command, like this For example with btsync server
Code: Select all
ps -ef|grep btsync|grep -c grep
. You get 1 if it is running and 0 if not.

if you have a pid file, you can use the command line, still with btsync server:
Code: Select all
cat /proc/`cat /var/run/btsync.pid`/cmdline|grep -c btsync
you get 0 if it is not running and >0 if it is running