unix - Keep log file of shell script execution until past few days -


am appending standard output , error of shell script execution on unix bok shown below

/home/mydir/shellscript.sh >> /home/mydir/shellscript.log 2>&1 

now wondering way keep logs going as 30 days else log file size keep on increasing. appreciate if can provide recommendations around same.

is long-running script (e.g. daemon)? or exits quickly? dynamically build log file's name based on today's date, new file gets generated time date changes:

#/bin/sh now=`date +%f` /home/mydir/shellscript.sh >> /home/mydir/shellscript-$now.log 2>&1 previous=`date --date='30 days ago' +%f` rm -f /home/mydir/shellscript-$previous.log 2>&1 

(added stale log removal).


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -