I had a task that I have to write up a simple bash script which in turn executes admin command from Websphere Application Server (WAS). I put it into /etc/cron.daily folder hoping it would be executed in a daily basis (at what time I have no idea). However I want to have a footprint of this script is kicked off by the system so I added echo statement.#!/bin/bash[foo command to execute]echo foo command is executed > /bpm/v8/logs/foo.logNow I have three questions.There is system log file from WAS (SystemOut.log). Is it possible to write output of echo to SystemOut.log file?If not, is there a way that I could append date/time stamp to foo.log file?How can I prevent foo.log file eating up disk space? I know that SystemOut.log file gets compressed saved with date/time stamp time to time. I think some sort of log rotate(?) program does it.Context of this problem is in rhel v6 64-bit machine.
How to write and handle custom log file properly?
files;logs
The answers to your questions:If the SystemOut.log file is owned by the same or more privileged account that runs the script, yes you can write to it, but I suggest not doing this, as you may need to provide that log to vendor for troubleshooting a problem one day and foreign entries in the log may throw them off and at the worst case they might refuse to help you because the file integrity was compromised (far chance but not non-existent)As long as the file/directory ownerships and permissions allow you, you can write this anywhere you want.You can add this log file to the logrotate scope and it will get recycled in the schedule desired. Or you can add a few lines after echo'ing the log line to scan the file and if it is larger than, say 10K lines, trim the first 9K lines and stash them somewhere in a compressed form. This is totally up to you.