Re: shell scripting - automating rotation of files in differentdirectories
On Thu, Jun 12, 2003 at 02:58:32PM -0400, Dave [Hawk-Systems] wrote: > have looked at a couple of the ports for log rotation and such, but none seem to Maybe cronolog could be useful to you: /usr/ports/sysutils/cronolog primarily for web log files... ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: shell scripting - automating rotation of files in differentdirectories
On Thu, Jun 12, 2003 at 02:58:32PM -0400 I heard the voice of Dave [Hawk-Systems], and lo! it spake thus: > For example, > > for($i=30; $i>0;$1--){ # 30 days is maximum retained > for LOG in `ls /users/*/logs/ | grep .$i'`; do > # move any of the previous logs into the current existing > # so that we don't add to number of logs per user > $prevLOG = strreplace(($i-1)($i) on $LOG) > mv $prevLOG $LOG > done > ) > > > Am thinking that the shell script will need to drop to awk to perform the > disection of the log number extensions... any thoughts on this/easier methods > before I sit down and devote some time to it? You want jot(1) and expr(1). Something along the lines of: for i in `jot 29 29 1`; do if [ -r /some/dir/log.${i} ] ; then mv -f /some/dir/log.${i} /some/dir/log.`expr "${i}" + 1` fi done (more simplistic than yours, since it doesn't recurse across directories, but the idea gets across) -- Matthew Fuller (MF4839) | [EMAIL PROTECTED] Systems/Network Administrator | http://www.over-yonder.net/~fullermd/ "The only reason I'm burning my candle at both ends, is because I haven't figured out how to light the middle yet" ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[EMAIL PROTECTED]"
shell scripting - automating rotation of files in differentdirectories
have looked at a couple of the ports for log rotation and such, but none seem to come close to the simplicity and complexity of what I am looking for. have user directories and log files in each directory... each user requests to have 1 day ro 30 days of logs made available for them to download at any given time. Looking for a way to simply touch or delete log files and have the script identify the correct rotation to. For example, for($i=30; $i>0;$1--){ # 30 days is maximum retained for LOG in `ls /users/*/logs/ | grep .$i'`; do # move any of the previous logs into the current existing # so that we don't add to number of logs per user $prevLOG = strreplace(($i-1)($i) on $LOG) mv $prevLOG $LOG done ) this way, if a user wants more logs, just touch (create empty) logs files, and the next time the script runs it will rotate all them... need less, simply delete the unneeded log files and they will not be rotated into. Am thinking that the shell script will need to drop to awk to perform the disection of the log number extensions... any thoughts on this/easier methods before I sit down and devote some time to it? thanks Dave ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[EMAIL PROTECTED]"