How to rotate catalina.out using cron job

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

By default, catalina.out file does not rollover, and with time it grows large. This script will be executed by a cron job, to tarball catalina.out file and empty the large file.

Solution

  1. First, create the executable backup.sh file

    backup.sh

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 #!/bin/bash #Backup catalina* in a folder /backups in user home SRCDIR="path/to/bamboo-installation-directory/logs" DESTDIR="/home/$USER/backups" DATE_WITH_TIME=`date "+%Y%m%d-%H%M%S"` FILE_NAME="Catalina-backup" BACKUP_FILE=$FILE_NAME$DATE_WITH_TIME TARGET="catalina.out" if [ ! -d "$DESTDIR" ]; then mkdir $DESTDIR fi cd $SRCDIR && \ tar -czvf $BACKUP_FILE.tar.gz catalina.out && \ mv $FILE_NAME* $DESTDIR && \ truncate --size=0 $TARGET >&2 exit 0
  2. Ensure the file is executable

    1 chmod +x /path/to/backup.sh
  3. create a cron job to run the script

    1 0 0 * * 5 /path/to/backup.sh >/dev/null 2>&1
Updated on April 2, 2025

Still need help?

The Atlassian Community is here for you.