IBM Support

Using cron_script utility to remove old files

Question & Answer


Question

How do I remove old files using the cron_script utiility?

Answer

The TNPMW is bundled with the cron_script utility that can be used to remove old files. It is located in:

[hostname:virtuo] /$WMCROOT/admin/common/cron

Normally, cron_script are setup in cron entries within the TNPMW installation. The following is an example of such an entry:

[hostname:virtuo]crontab -l | grep cron_script


0 1 * * * /appl/virtuo/admin/common/cron/cron_script -r -d 31 /data/trace_archive1 \*.log.\*

To remove a file using the cron_script utility, complete the following steps as user virtuo:

1. Move to the directory where the cron_script is located:


cd /$WMCROOT/admin/common/cron

2. Execute the following command:
./cron_script -r -d <days> <dirname> <filename>

The -r option must be used for the script to 'remove' files.

The parameters to be included with the -r option to remove old files are described in the Table below:

OptionDescription
-d <days>The -d option is optional. Use the <days> argument to specify the age of the file in days. Without this option, all files would be removed regardless of age.
<dirname>The directory the log files are currently stored in.
<filename>The filename of the file you want to remove.

Note: Multiple files can be removed at the same time using the (*) wildcard.

The following is an example of executing the given cron entry above manually:

/appl/virtuo/admin/common/cron/cron_script -r -d 31 /data/trace_archive1 \*.log\*

where all '*.log*' files that are dated 31 days or older will be removed in the directory '/data/trace_archive1'.

[{"Product":{"code":"SSKGHX","label":"Tivoli Netcool Performance Manager for Wireless"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Not Applicable","Platform":[{"code":"PF027","label":"Solaris"}],"Version":"9.1.1.12;9.1.2;9.2","Edition":"All Editions","Line of Business":{"code":"LOB45","label":"Automation"}}]

Product Synonym

TNPMW

Document Information

Modified date:
23 June 2018

UID

swg21406244