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 2 * * * cd /var/www/html/server/cron; ./ust_del_record_60_days.sh >> /var/log/ust_cron.log 2>&1
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
# Backup the database every Sunday at 3AM
0 3 * * 0 cd /var/www/html/server/cron; ./ust_backup_dh.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

There are currently no cron job examples for Multi-DB Agency setups. Those cron jobs will only delete data in the main database.

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

# Delete zero second recordings (potential bots)
server/cron/ust_del_zero_sec_rec.sh

# Create a backup of the main database (in /tmp/backups/)
server/cron/ust_backup_dh.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