Advertisement

06.06.2008 at 07:20AM PDT, ID: 23463787
[x]
Attachment Details

crontab not running full script

Asked by courtenayt in Shell Scripting, Unix Operating Systems, Linux Administration

Tags: unix, shell

Hi,

I'm having a very bizarre problem.  I have the script called  svcschk
 (listed below) under the directory scripts.  I have a crontab set up to run it every minute with the following:


[root@teska /]# crontab -l
* * * * *    /scripts/svcschk > /dev/null 2>&1

If I stop tomcat and/or postgres manually and then manually run scripts/svcschk, then both will be restarted (or if only 1 was stopped, the one that was stopped will be restarted).  

The problem I'm having is for some reason, if tomcat and postgres (or just postgres) are stopped, when the crontab runs, it only seems to start tomcat and doesn't start postgres.

Does anyone have any idea what might be causing this bizarre behavior?  I swear that it used to work with no problems.  I'm running CentOs 5.

Thanks,
CourtenayStart Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
#!/bin/bash
# Services Restarter - Automatically restart tomcat if it dies
/bin/netstat -ln | /bin/grep ":8080 " | /usr/bin/wc -l | /bin/awk '{if ($1 == 0) system("/sbin/service tomcat6 start") }'
# Service Restarter - automatically restart postrgres if it dies
postgres=`/bin/netstat -an | /bin/grep -i listen | /bin/grep ^tcp | /bin/grep 5432`
if [ "$postgres" == "" ]; then
        service postgresql start
fi
[+][-]06.06.2008 at 07:29AM PDT, ID: 21729399

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Shell Scripting, Unix Operating Systems, Linux Administration
Tags: unix, shell
Sign Up Now!
Solution Provided By: omarfarid
Participating Experts: 1
Solution Grade: A
 
 
[+][-]06.06.2008 at 08:50AM PDT, ID: 21730187

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628