Document Type | Technical Information
Category | Administration
Applicable Product Versions | 6FS07, 6FS07PS, 7FS02, 7FS02PS
Document Number | TADTI030
Overview
This guide explains how to set up crontab for automatic deletion of archive files.
Method
1. Check the archive path of the DB (Query using V$PARAMETER view table)
SQL> SELECT NAME, VALUE FROM V$PARAMETERS WHERE NAME = 'LOG_ARCHIVE_DEST'; NAME ---------------------------------------------------------------- VALUE --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- LOG_ARCHIVE_DEST /data/tibero_data7/archive/
2. Create arch_del.sh file that selects and deletes all files named *.arc older than a specific time
-- Example shell file to automatically delete archive files older than 7 days
$ cat arch_del.sh
find /data/tibero_data7/archive/ -name "*.arc" -mtime +7 -exec rm -f {} \;
3. Register the shell file in crontab
It is recommended to set crontab as the root account rather than a general user account.
# crontab -e (run from root directory) -- To apply crontab deletion schedule every minute * * * * * sh <absolute path of arch_del.sh file>/arch_del.sh >> <absolute path of arch_del.sh file>/arch_del.log 2>&1
crontab Information
crontab | Description |
|---|---|
crontab -l | List scheduled jobs |
crontab -e | Edit scheduled jobs |
crontab -r | Delete scheduled jobs |
crontab -u | Root administrators can view, delete, or edit crontab files of specified users |
Field | Description |
|---|---|
Minute (0-59) | Set minute (0~59). If * is set, runs every minute. |
Hour (0-23) | Set hour (0~23). If * is set, runs every hour. |
Day (1-31) | Set day (1~31). If * is set, runs daily. |
Month (1-12) | Set month (1~12). If * is set, runs monthly. |
Day of Week (0-7) | Set day of week (0~7). If * is set, runs every day from Monday to Sunday. |