diff options
author | Simon Rettberg | 2014-10-09 16:01:11 +0200 |
---|---|---|
committer | Simon Rettberg | 2014-10-09 16:01:11 +0200 |
commit | e1dc0d3c99217504de2ac8467156274786efc0bd (patch) | |
tree | 130d7fed1fff8aaaffe5942cf2a3d6bb1dad03c8 /apis/cron.inc.php | |
parent | Minor fixes and improvements (diff) | |
download | slx-admin-e1dc0d3c99217504de2ac8467156274786efc0bd.tar.gz slx-admin-e1dc0d3c99217504de2ac8467156274786efc0bd.tar.xz slx-admin-e1dc0d3c99217504de2ac8467156274786efc0bd.zip |
Big load of changes
- Added callback functionality for taskmanager tasks. You can launch
a task and define a callback function to be run when the task finished.
This requires activating the cronjob
- Added cron functionality: Add cronjob that calls the cron api every 5
minutes to use it. (See cron.inc.php)
- Added eventlog
- Added missing translations
- Merged main-menu-login and main-menu-logout
Diffstat (limited to 'apis/cron.inc.php')
-rw-r--r-- | apis/cron.inc.php | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/apis/cron.inc.php b/apis/cron.inc.php new file mode 100644 index 00000000..2d0fc66c --- /dev/null +++ b/apis/cron.inc.php @@ -0,0 +1,28 @@ +<?php + +/* + * cronjob callback. This script does periodic checks, logging, + * housekeeping etc. Should be called every 5 mins by cron. + * Make a crontab entry that runs this as the same user the + * www-php is normally run as, eg. */ +// */5 * * * * www-data php /path/to/api.php cron + +if (!isLocalExecution()) + exit(0); + +switch (mt_rand(1, 10)) { +case 1: + Database::exec("DELETE FROM clientlog WHERE (UNIX_TIMESTAMP() - dateline) > 86400 * 90"); + break; +case 2: + Database::exec("DELETE FROM eventlog WHERE (UNIX_TIMESTAMP() - dateline) > 86400 * 90"); + break; +case 3: + Database::exec("DELETE FROM property WHERE dateline <> 0 AND dateline < UNIX_TIMESTAMP()"); + break; +case 4: + Database::exec("DELETE FROM callback WHERE (UNIX_TIMESTAMP() - dateline) > 86400"); + break; +} + +Trigger::checkCallbacks(); |