Steps for Deleting Logs Older than 60 Days
1. Create a shell script which contains commands to delete log files of all the servers. For example if the filename is “delete_logs_2mnths_older.sh” run the below command.
sudo vi delete_logs_2mnths_older.sh
And enter the commands as mentioned below.
<SNIP>
find /u07/oracle/middleware/user_projects/domains/wci_domain/servers/bam_server1/logs -mtime +60 -type f -delete
find /u07/oracle/middleware/user_projects/domains/wci_domain/servers/UCM_server1/logs -mtime +60 -type f -delete
find /u07/oracle/middleware/user_projects/domains/wci_domain/servers/soa_server1/logs -mtime +60 -type f -delete
find /u07/oracle/middleware/user_projects/domains/wci_domain/servers/AdminServer/logs -mtime +60 -type f -delete
find /u07/oracle/middleware/user_projects/domains/wci_domain/servers/IPM_server1/logs -mtime +60 -type f -delete
</SNIP>
2. After writing the script file then you need to give permissions for the file to execute. Run the below command.
sudo chmod 777 delete_logs_2mnths_older.sh
3. Now we have to make an entry in Crontab for “delete_logs_2mnths_older.sh” file to execute periodically.
Run the below command.
sudo crontab –e
Below is the entry we make in Crontab which says that “delete_logs_2mnths_older.sh” should be executed every day at 9pm PST (SDSU timing).
0 21 * * * /tmp/Delete_Older_logs/delete_logs_2mnths_older.sh
The Cron job works in below fashion.
4. We need to restart the Cron job. Execute the below commands.
Goto : cd /etc/init.d and run below command
sudo ./crond restart
You will get below message.
No comments:
Post a Comment