Hi there, never mind. I wanted to do a Perl Script of the commands I provided but had some help doing it in Bash script so that pretty much did the job.
#!/bin/bash
OLD_HIST_DIR="/var/log/user_history/old_logs"
HIST_DIR="/var/log/user_history"
MNTH_DEST_DIR="/var/log/user_history/old_logs/$(date +'%m')"
# date +'%m' gives number corresponding to the current month in 01,02,
+...11,12 fashion
mkdir -p "${MNTH_DEST_DIR}" "${OLD_HIST_DIR}" # This will create the
+directory if not present
cp -p ${HIST_DIR}/*history ${OLD_HIST_DIR}
gzip -9 ${OLD_HIST_DIR}/*history
mv ${OLD_HIST_DIR}/*.gz ${MNTH_DEST_DIR}
@admins you may close this thread
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.