Skip to content

Commit

Permalink
Randomise cron times to reduce server overload
Browse files Browse the repository at this point in the history
  • Loading branch information
wpf500 committed Dec 17, 2024
1 parent 07c8364 commit 6ed049d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions apps/backend/crontab
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Add node to the PATH
PATH=/usr/local/bin:/usr/bin:/bin

# min hour day month weekday command
0 1 * * * su node -c 'cd /opt/apps/backend/ && node ./built/tools/mailchimp/sync.js' > /proc/1/fd/1 2>&1
0 1 * * * su node -c 'cd /opt/apps/backend/ && node ./built/tools/start-gifts.js' > /proc/1/fd/1 2>&1
0 1 * * * su node -c 'cd /opt/apps/backend/ && node ./built/tools/process-segments.js' > /proc/1/fd/1 2>&1
# Spread the jobs out over a few minutes to avoid overloading the server
0 1 * * * su node -c 'cd /opt/apps/backend/ && sleep $((RANDOM \% 120)) && node ./built/tools/mailchimp/sync.js' > /proc/1/fd/1 2>&1
5 1 * * * su node -c 'cd /opt/apps/backend/ && sleep $((RANDOM \% 120)) && node ./built/tools/start-gifts.js' > /proc/1/fd/1 2>&1
10 1 * * * su node -c 'cd /opt/apps/backend/ && sleep $((RANDOM \% 120)) && node ./built/tools/process-segments.js' > /proc/1/fd/1 2>&1

0 comments on commit 6ed049d

Please sign in to comment.