run:R W Run
7.55 KB
2026-04-08 19:24:59
R W Run
1.56 KB
2026-04-08 19:24:57
R W Run
1.34 KB
2026-04-08 19:24:56
R W Run
787 By
2026-04-08 19:24:58
R W Run
29.66 KB
2026-04-08 19:24:57
R W Run
6.35 KB
2026-04-08 19:24:57
R W Run
851 By
2026-04-08 19:24:58
R W Run
4.56 KB
2026-04-08 19:24:57
R W Run
11.08 KB
2026-04-08 19:24:56
R W Run
2.83 KB
2026-04-08 19:24:59
R W Run
40 By
2026-04-08 19:24:56
R W Run
39.18 KB
2026-04-08 19:24:57
R W Run
69.96 KB
2026-04-08 19:24:57
R W Run
310 By
2026-04-08 19:24:57
R W Run
12.03 KB
2026-04-08 19:24:57
R W Run
error_log
📄cleanup_dl_service4u.php
1#!/usr/bin/env php
2<?php
3/**
4 * Cleanup script for /clients/dl/ temp attachment folder
5 * Deletes any file older than 24 hours based on file modification time
6 * Run daily via cron:
7 * 0 3 * * * /opt/cpanel/ea-php81/root/usr/bin/php -q /home/theservice4u/public_html/clients/crons/cleanup_dl.php
8 */
9
10$dlDir = '/home/theservice4u/public_html/clients/dl/';
11$maxAge = 86400; // 24 hours in seconds
12$now = time();
13$deleted = 0;
14$errors = 0;
15
16if (!is_dir($dlDir)) {
17 echo "[" . date('Y-m-d H:i:s') . "] ERROR: Directory not found: {$dlDir}\n";
18 exit(1);
19}
20
21$files = glob($dlDir . '*');
22
23if (empty($files)) {
24 echo "[" . date('Y-m-d H:i:s') . "] Nothing to clean up.\n";
25 exit(0);
26}
27
28foreach ($files as $file) {
29 // Skip directories and this script itself
30 if (!is_file($file) || basename($file) === 'cleanup_dl.php') {
31 continue;
32 }
33
34 $age = $now - filemtime($file);
35
36 if ($age > $maxAge) {
37 if (unlink($file)) {
38 echo "[" . date('Y-m-d H:i:s') . "] Deleted: " . basename($file) . " (age: " . round($age / 3600, 1) . "hrs)\n";
39 $deleted++;
40 } else {
41 echo "[" . date('Y-m-d H:i:s') . "] ERROR: Could not delete: " . basename($file) . "\n";
42 $errors++;
43 }
44 }
45}
46
47echo "[" . date('Y-m-d H:i:s') . "] Done. Deleted: {$deleted} file(s), Errors: {$errors}.\n";
48