Crontab¶
The software utility cron (https://en.wikipedia.org/wiki/Cron) is a time-based job scheduler in Unix-like computer operating systems. People who set up and maintain software environments use cron to schedule jobs (commands or shell scripts) to run periodically at fixed times, dates, or intervals. It typically automates system maintenance or administration—though its general-purpose nature makes it useful for things like downloading files from the Internet and downloading email at regular intervals; “cron” is most suitable for scheduling repetitive tasks. Scheduling one-time tasks is often more easily accomplished using the associated “at” utility.
Command line utilities¶
A series of command are available via command line, and can be called with “python manage.py”. Available commands are:
create_export_dwh: create Excel export
create_monthly_period: create a current month period object in the database
update_currencies: update currency exchanges
check_website_status: check the status of the website
send_mails: send all mail messages with errors
dashboard_notification_creation: create mails for notification about dashboards
import_batch_command: import file groups listed under Admin->Imports->Batch
execute_queries_command: execute SQL queries listed under Admin->Imports->SQL Explorer
close_old_periods: Close the old periods. Users can’t import on that period after the deadline
insert_kpis_from_file: create all kpis based on kpi_list.xlsx file. Please use same column name for import
send_reminder_email_for_import: send email reminder if not all import are completed for By Whom
run_ml_files: execute the machine learnign procedure
Call the command via ./run-make.sh script. For example
./run-make.sh create_export_dwh
Scheduling activities¶
Once scripts are ready, it is possible to schedule their execution via crontab.
To edit the crontab use the command:
crontab -e
For example, one can add this list:
30 04 * * * /run-make.sh create_export_dwh
0 1 * * * ./run-make.sh populate_kpi_aval_table
0 0 1 * * ./run-make.sh create_monthly_period
0 0 2 * * ./run-make.sh update_currencies
0 0 1 * * ./run-make.sh do_clustering
0 0 1 * * ./run-make.sh send_reminder_email_for_import
0 4 * * * /run-make.sh run_ml_files