This repository was archived by the owner on May 26, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathcron.sh
More file actions
37 lines (26 loc) · 1.05 KB
/
cron.sh
File metadata and controls
37 lines (26 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
# Path to your instance without trailing slash
rootDir=/var/www/legacy-rp-admin-v3
# $1 is the cluster (c3, c2, etc.)
# $2 is the dev-token
runCronJobs() {
echo -n "Running jobs for $1..."
echo -n $(curl -s https://$1.legacy-roleplay.com/cron/bans?token=$2)"..."
echo $(curl -s https://$1.legacy-roleplay.com/cron/economy?token=$2)
}
# $1 is the directory
countFiles() {
ls $1 -1 | wc -l
}
# For each of your instances copy this
runCronJobs "c3" "my-dev-token"
# Automatically delete log files older than 14 days
before=$(countFiles $rootDir/storage/logs/)
find $rootDir/storage/logs/ -mindepth 1 -type f -mtime +14 -delete
after=$(countFiles $rootDir/storage/logs/)
echo "Removed "$(($before - $after))" log files"
# Automatically delete sessions older than 2 days
before=$(countFiles $rootDir/storage/framework/session_storage)
find $rootDir/storage/framework/session_storage -mindepth 1 -type f -mtime +2 -delete
after=$(countFiles $rootDir/storage/framework/session_storage)
echo "Removed "$(($before - $after))" .session files"