Welcome to WebmasterWorld Guest from 107.22.7.35

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

perl scripts automatically run on the apache server

perl scripts automatically run on the apache server in linux

     
9:52 am on Aug 30, 2002 (gmt 0)

10+ Year Member



I need the program in perl that it automatically takes the input from the log file and updates in mysql database. That is the log file data changes every seconds. while the data changes in the logfile, the script should take the data and put it into the database. That is the script is always running and watching in the server for the log file updates. How to do this in perl. Please help me to solve this.

Thanks.
S.Ramesh.

10:25 am on Aug 30, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This is from recipe 8.5 in the Perl Cookbook:

Read until end of file. Sleep, clear the EOF flag, and read some more. Repeat until interrupted.

for (;;) { 
while (<FH>) { add to database }
sleep $SOMETIME;
seek (FH, 0, 1);
}
12:21 pm on Aug 30, 2002 (gmt 0)

10+ Year Member



hello friend,

Thanks for your reply. But this code runs if we run the script in the konsole. But I need the script which automatically runs while the server starts run.

Thanks.
S.Ramesh.

12:36 pm on Aug 30, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I might be wrong but how about adding the perl script to the init script that starts and stops your webserver?
12:44 pm on Aug 30, 2002 (gmt 0)

10+ Year Member



You are not wrong. The script is working correctly.

We run this script by ourself in konsole. But my need is, " this program should be controlled by the server. If the server starts running, this program also need to run." That is, this program is controlled by the server.

Thanks!
S.Ramesh.

1:15 pm on Aug 30, 2002 (gmt 0)

10+ Year Member



That script varies depending on your distro. At Debian, for example, you'd add a line at the start) case of /etc/init.d/apache.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month