我是cronjobs的新手,在学校上过一些课程,但是老师对此并不了解,谢谢......我写了一个脚本,在3天后没有激活用户时自动删除用户,或者不活跃90天。
但是我想通过cronjob运行该脚本...我的主机使用Directadmin并且我已经使用了google很多但没有任何作用...... :(
我知道计时器是如何工作的,但在某个地方出错 - , -
也许你们这里有人可以帮助我?
这是我使用的行:/ usr / bin / php -q / home / 用户名 / domains / Domain_name / public_html / 文件夹 / _ dell.php
这是_dell.php
中的php脚本BTW php脚本有效,当我自己运行时它运行完美(y)
<?php
include "includes/conn.php";
// Delete users die na 3 dagen nog niet zijn geactiveerd.
$ongeactiveerd = time() - (60 * 60 * 24 * 3); // staat gelijk aan 3 dagen.
$ongeactiveerd1=mysqli_query($server,"SELECT * FROM users WHERE rank < 1 AND status = 0 AND laatstgezien < $ongeactiveerd");
if(mysqli_num_rows($ongeactiveerd1) > 0) {
$test = array();
while($row = mysqli_fetch_array($ongeactiveerd1)) {
$test[] = $row['username'];
}
foreach($test as $testkey => $testuser) {
$test[$testkey] = "'".mysqli_real_escape_string($server,$testuser)."'";
}
$homo = join(', ', $test);
echo $homo;
$query = "DELETE FROM users WHERE username IN ($homo)";
$query1 = "DELETE FROM pm WHERE verzender IN ($homo)";
$query2 = "DELETE FROM pm WHERE ontvanger IN ($homo)";
echo "<br>".$query."<br><br>".$query1."<br><br>".$query2;
//exit();
$result = mysqli_query($server,$query) or die (mysqli_error($server));
$result1 = mysqli_query($server,$query1) or die (mysqli_error($server));
$result2 = mysqli_query($server,$query2) or die (mysqli_error($server));
}
else {
echo "Er zijn geen on-geactiveerde gebruikers.<br><br>";
}
// Delete users die 90 dagen inactief zijn.
$inactief = time() - (60 * 60 * 24 * 90); // staat gelijk aan 90 dagen || 3 maanden.
$status1 = 1;
$inactief1=mysqli_query($server,"SELECT * FROM users WHERE rank < 1 AND status = 1 AND laatstgezien < $inactief");
if(mysqli_num_rows($inactief1) > 0) {
$test1 = array();
while($row = mysqli_fetch_array($inactief1)) {
$test1[] = $row['username'];
}
foreach($test1 as $test1key => $test1user) {
$test1[$test1key] = "'".mysqli_real_escape_string($server,$test1user)."'";
}
$homo1 = join(', ', $test1);
echo $homo1;
$queryy = "DELETE FROM users WHERE username IN ($homo1)";
$queryy1 = "DELETE FROM pm WHERE verzender IN ($homo1)";
$queryy2 = "DELETE FROM pm WHERE ontvanger IN ($homo1)";
echo "<br>".$queryy."<br><br>".$queryy1."<br><br>".$queryy2."<br>";
//exit();
$resultt = mysqli_query($server,$queryy) or die (mysqli_error($server));
$resultt1 = mysqli_query($server,$queryy1) or die (mysqli_error($server));
$resultt2 = mysqli_query($server,$queryy2) or die (mysqli_error($server));
}
else {
echo "Er zijn geen inactieve gebruikers.";
}
?>