diff --git a/scripts/README.md b/scripts/README.md index d393d479..2cafefe3 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -3,11 +3,30 @@ ## `get_correct-set.sh` On the production machine `get_correct_set.sh` is set to run as cronjob on the root user. +For the cron job to run successfully a virtual environment for Python 3.8+ must be created in `/home/cs334/mirrulations/scripts/.venv`. -The current cron job is as follows: +The command to do so is as follows + +```bash +cd /home/cs334/mirrulations/scripts +/usr/bin/python3.8 -m venv .venv +source .venv/bin/activate +pip install -r requirements.txt +deactivate +``` + +Now `get_correct_set.sh` will be able to be run as a script. +To add the cronjob to the root users crontab run the following + +```bash +sudo crontab -e +``` + +Select an editor you feel comfortable with the line below if it is not already there ``` 0 */6 * * * /home/cs334/mirruations/scripts/get_correct_set.sh ``` +This line tells the cron daemon to run the script every 6 hours. Output logs are stored in `/var/log/mirruations_counts.log`. diff --git a/scripts/get_correct_set.sh b/scripts/get_correct_set.sh index 637ff758..33f2c33a 100755 --- a/scripts/get_correct_set.sh +++ b/scripts/get_correct_set.sh @@ -6,7 +6,7 @@ START_TIME=$(date -Iseconds) echo "$START_TIME: Running" >> $LOG_FILE cd $WORK_DIR -source .venv/bin/python3/activate +source .venv/bin/activate ./get_counts.py -o "/tmp/mirrulations_$START_TIME.json" redis 2>> $LOG_FILE && ./correct_counts.py -i "/tmp/mirrulations_$START_TIME.json" -o "/tmp/mirrulations_${START_TIME}_corrected.json" 2>> $LOG_FILE &&