Am appending the standard output and error of the shell script execution on a unix bok like shown below
/home/mydir/shellScript.sh >> /home/mydir/shellScript.log 2>&1
Now am wondering a way to keep logs going back as much as say 30 days else the log file size will keep on increasing.
Would appreciate if anyone can provide recommendations around the same.
Is this a long-running script (e.g. daemon)? Or does it do something then exits quickly? You could dynamically build the log file’s name based on today’s date, so a new file gets generated any time the date changes:
(added stale log removal).