Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script Problem

Status
Not open for further replies.

ponetguy2

MIS
Aug 28, 2002
442
US
I created a script which counts how many httpd connections we have. I scheduled a cronjob to run the script every hour.

The problem is, I get the time and date on the output file, but I don't get the netstat count. When I run the script manually it works, but w/cronjob does not.
Any ideas? Please advise.

Here is the script:

#!/bin/sh


netstat -n | grep 192.168.1.1.443 > /secure/connection_out.txt
echo "==================================" >> /secure/connection_report.txt
date >> /secure/connection_report.txt
wc -l connection_out.txt >> /secure/connection_report.txt
echo "==================================" >> /secure/connection_report.txt

exit 0
 
Specify full paths to all the commands in your script if your are going to call it from cron.

Reason: Cron doesn't have an environment so you will either need to source the users environment the cron job is running under or specify full paths in your script.


Regards,
Chuck
 
You shouldn't need full paths to any of those commands because cron does have a minimal PATH defined which does include /usr/bin, where all of those commands are located.

The problem is that you haven't specified the full path to connection_out.txt after the wc command.

Annihilannic.
 
thank you again for the replies. you guys are great!!!

i made the changes. hopefully it works. :)
 

If running apache, mod_status and the /server-status URL give a great visual representation of the status of your webserver. One could "wget" it and parse it for a better view of what is happening.

gene
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top