Cron Job - Auto Expire Pastes (Bash/PHP)

Text Views: 79 • Feb 08, 2026 • Never expires
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
🛡️

Ad Blocker Detected

PasteBin.site is free to use thanks to our sponsors. Please consider disabling your ad blocker or whitelisting our site to support our servers.

Learn More