How to rotate catalina.out using cron job

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

Note that this knowledge base article was created for the Data Center version of the product. Data Center knowledge base articles 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

Purpose

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
    #!/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

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

    0 0 * * 5 /path/to/backup.sh >/dev/null 2>&1





Last modified on Jan 27, 2025

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.