Auto-delete old data (cron jobs)

You can use the provided cron jobs to automatically delete old data in order to keep the database size low and maintainable for many years.

Most data usage comes from heatmaps and recordings.

How to run the cron jobs

Note: This assumes that your dashboard is installed at /var/www/html/. Update the paths accordingly if your dashboard is installed at a different location. You might first have to run sh /var/www/html/server/cron/set_exec_permissions.sh to make sure that cronjob can execute the scripts.

Edit the crontab file to set what scripts to execute when, by running crontab -e. Add the scripts you want to be executed, like this:

crontab -e
# ... previous crontab content ...

# UXWizz cron jobs
0 3 * * * cd /var/www/html/server/cron; ./ust_del_heatmap_60_days.sh >> /var/log/ust_cron.log 2>&1
0 4 * * * cd /var/www/html/server/cron; ./ust_limit_record_number.sh >> /var/log/ust_cron.log 2>&1

You can use the nano editor for modifying this file. You can press CTRL+O to save the file and CTRL+X to exit. Notes

0 3 * * * * = Every day at 3 AM Tool to understand the cron time syntax: https://crontab.cronhub.io/

/var/www/html/server/cron/log.txt Will contain the execution date and time logs for the scripts that were run.

Built-in example scripts

UXWizz comes with some helper and example scripts that can be used for cron jobs.

/var/www/html/
###################
# Core scripts
###################
server/cron/ust_execute_query.sh
server/cron/set_exec_permissions.sh

###################
# Built-in example scripts to be used as cron jobs
###################

# Delete heatmap data older than 60 days (data saving)
server/cron/ust_del_heatmap_60_days.sh

# Delete recording data older than 60 days (data saving)
server/cron/ust_del_record_60_days.sh

# Delete all data older than 1 year (session retention)
server/cron/ust_del_visitors_1_year.sh

# Enforce domain record limit (delete sessions going over the set domain limit)
server/cron/ust_limit_record_number.sh

To change the retention numbers or create other scripts, you can copy one of the example .sh files and edit it. (e.g. change interval from 60 days to 6 months).

Last updated