-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Randomise cron times to reduce server overload
- Loading branch information
Showing
1 changed file
with
4 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |