My provider doesn`t allow any user cronjobs, but I have to perform a regular task (set back passwords ).
So I just wrote a small script to the job for me, but I am not sure if it will need to much resources (and because of this would be killed by my provider)

Does anyone know a better solution than continuously running a perl script?

Thanks for your help in advance.

Sven

#!/bin/perl -w
BEGIN {
$| = 1;
push(@INC,'/htdocs/www/cgi-bin/lib');
use DBI;
}


#Version 0.1





my $date = localtime(time);
my $dsn = ''; # Data Source Name
my $db_user = ''; # Database User
my $db_pass = ''; # database pass
my $logfile = "cron_log.txt"; # Logfile


open (LOG, ">>$logfile") || mydie($_);

&pw_switch();

sub pw_switch {

sleep(8*60*60);
my $new_password = pw_create();
my $dbh = DBI->connect( $dsn, $db_user, $db_pass) || mydie($DBI::errstr);
#my $number = $dbh->do("select count(*) from memberscopy where
my $del_pw = $dbh ->do( $sql ) || mydie($DBI::errstr);
print LOG " $date -- $sql\n";

$dbh->disconnect;
close (LOG);
print qq ~
<html>
<head>
<title>Password switching done</title>
</head>
<body bgcolor=red>
<h1>Password switched</h1>
</body>
</html>
~;


}

sub pw_create {
my $password = join '', ("1".."9","a".."z","A".."Z",0..9)[map {rand 36} 0..9];
$password = substr($password, 0, 8);


chomp $password;
return ($password);
}



sub mydie {
open (LG, ">>.Mydie_cron.txt");
print LG "$_ -- $date \n";
close (LG);
exit;
}


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to