UXWizz
WebsitePricingDemoTwitter (X)
  • Introduction
  • 🛠️ Installation
    • Requirements
      • Limitations
      • Server specs (CPU, RAM)
    • Installation guide
      • Uploading the script
      • Creating a MySQL database
      • Running the installer
    • Install on a new server
      • Ubuntu 20.04 (or higher)
      • DigitalOcean
    • Docker
      • Via Docker Compose
      • Standalone Docker image
    • Adding the tracking code
      • Automatic SPA pageview tracking
      • Add tracker to Next.js App
      • Add tracker to React Router App
    • Optimization tips
      • MySQL/MariaDB
      • Auto-delete old data (cron jobs)
      • Apache
    • Frequently Asked Questions
  • 🔧JavaScript API
    • Tags
    • Events
    • Hooks/callbacks
    • Other API functions
    • Session Recording
      • Ignore specific elements
  • 📖Guides and features
    • Goals (NEW!)
    • Ask AI (NEW!)
    • Basic usage
    • A/B testing
    • Usage tips
    • Dashboard user access level
    • Resetting the admin password
    • Database querying
    • Technical details
      • IP Geolocation
    • Troubleshooting
      • Agency
        • MultiDB
      • Dashboard
        • Refreshing dashboard sub-page leads to 404 error
        • Website iframe not loading (x-frame-options)
        • License says "invalid"
        • Updating Fails
      • Tracking
        • No data is being recorded
        • Can't include tracker via Google Tag Manager
        • The A/B test JS file is missing
      • WordPress
        • Cloudways 403 Forbidden screen on WordPress
        • NGINX 403 Forbidden screen on WordPress
    • Extending the dashboard
    • Support
    • Migrating to a new server
  • 🎓Useful Examples
    • Feedback form (polls)
    • Tracking 404 Pages
    • Tracking UTM parameters
    • Tracking Google Ads GCLID
    • Storing user device types
    • Track video playback
  • 📜About
    • Changelog
    • Personal Data Information
    • Privacy Policy (uxwizz.com)
    • Licenses and pricing
    • [Deprecated] License Subscriptions
Powered by GitBook
On this page
  • How to run the cron jobs
  • Built-in example scripts

Was this helpful?

  1. 🛠️ Installation
  2. Optimization tips

Auto-delete old data (cron jobs)

PreviousMySQL/MariaDBNextApache

Last updated 7 months ago

Was this helpful?

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 .

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:

/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).

recordings
https://crontab.cronhub.io/