-
Notifications
You must be signed in to change notification settings - Fork 1
Setting up a cronjob
You can set up a cronjob on your machine so that a file automatically runs at a specified date and time. You can check out this tutorial for all steps on how to create a cronjob.
I suggest setting up the traffic requester module to be run once a week (although it technically only needs to be run every 13 days). My cronjobs are set to run at 3:00AM UTC+0 to be able to reliably pull the previous days data. This is an example for running the main.py file one a week at 3:00AM UTC+0 (this translates to 19:00 PST).
0 19 * * 6 <path-to-project>/gth/main.py
To receive email updates less often, you could choose to set up multiple cronjobs so that the traffic requester module pulls the latest information once a week, but the analytics and email sender modules only run once a month. An hour between each module is wildly excessive for my repositories, but I don't know how many repositories you may have.
# run the traffic requester at least once a week
0 19 * * 6 <path-to-project>/gth/lib/traffic_requester.py
# also pull the latest info on the first of each month
0 19 1 * * <path-to-project>/gth/lib/traffic_requester.py
# run analytics and email sender on the first day of each month
0 20 1 * * <path-to-project>/gth/lib/analytics.py
0 21 1 * * <path-to-project>/gth/lib/email_sender.py
Note: don't forget to make whatever file(s) you run in the cronjob executables.
chmod +x main.py