Code Sample |
#!/bin/bash lognumber=$(date +%Y%W) exec touch filename.$lognumber |
Code Sample |
#!/bin/bash # set variables lognumber=$(date +%Y%W) logday=$(date [whatever you want -- standard date, day of week, etc.]) # if you want a timestamp: echo $logday >> filename.$lognumber # this line does what you seem to want: cat thefileyouwantlogged >> filename.$lognumber # the next two entries are to clear and restart the daily log file: rm thefileyouwantlogged touch thefileyouwantlogged |
Code Sample |
#!/bin/sh - echo "" printf %s "Rotating log files:" cd /var/log for i in system.log; do if [ -f "${i}" ]; then printf %s " ${i}" if [ -x /usr/bin/gzip ]; then gzext=".gz"; else gzext=""; fi if [ -f "${i}.5${gzext}" ]; then mv -f "${i}.5${gzext}" "${i}.6${gzext}"; fi if [ -f "${i}.4${gzext}" ]; then mv -f "${i}.4${gzext}" "${i}.5${gzext}"; fi if [ -f "${i}.3${gzext}" ]; then mv -f "${i}.3${gzext}" "${i}.4${gzext}"; fi if [ -f "${i}.2${gzext}" ]; then mv -f "${i}.2${gzext}" "${i}.3${gzext}"; fi if [ -f "${i}.1${gzext}" ]; then mv -f "${i}.1${gzext}" "${i}.2${gzext}"; fi if [ -f "${i}.0${gzext}" ]; then mv -f "${i}.0${gzext}" "${i}.1${gzext}"; fi if [ -f "${i}" ]; then touch "${i}.$$" && chmod 640 "${i}.$$" && chown root:admin "${i}.$$" mv -f "${i}" "${i}.0" && mv "${i}.$$" "${i}" && if [ -x /usr/bin/gzip ]; then gzip -9 "${i}.0"; fi fi fi done |
Code Sample |
#!/bin/sh - mkdir /path/to/weekly/backup/$(date +%W-%y) cp /path/to/files/filename.[0-6].gz /path/to/weekly/backup/$(date +%W-%y)/ |