If logrotate doesn't work for you, you can do this. Don't use the default nohup.out and you should be ok.
First create a little script called "logger" that looks like this.
Code:
#!/bin/ksh
unset IFS
while read LINE
do
LOGFILE=${1:-logfile}.$(date '+%Y%m%d').log
print "${LINE}" >> ${LOGFILE}
done
Then, run your command like this...
Code:
nohup myscript.sh 2>%1 | ./logger myscript &
This will run your script (or program, or whatever) in the background, and the little "logger" script will automatically roll the log into a new file each day. The first parameter to "logger" will be the name of the log file. It will have the date (YYYYMMDD) and ".log" appended to it (example "myscript.20121231.log"). Changing the date format will change how often the log is "rolled".
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.