Cron Job - Auto Expire Pastes (Bash/PHP)
Cron Job - Auto Expire Pastes (Bash/PHP)
===========================================
#!/bin/bash
# /pastetext/cron/expire_pastes.sh
php /var/www/pastetext/scripts/expire.php
# expire.php content:
<?php
$pdo = new PDO('mysql:host=localhost;dbname=pastetext', $u, $p);
$stmt = $pdo->prepare('DELETE FROM pastes WHERE expires_at < NOW()');
$stmt->execute();
echo "Expired " . $stmt->rowCount() . " pastes\n";
?>
# crontab -e: 0 2 * * * /pastetext/cron/expire_pastes.sh
Featured
Advertisement
Category
Action