I admit I am terrible with scripting, so when I was asked to store users' command history lines and zip them on monthly basis what I did was to create a file "user_history_Feb" with the following contents:
Part A
[root@H99XXX bin]# more user_history_Feb
cp -p /var/log/user_history/*history /var/log/user_history/old_logs/
gzip -9 /var/log/user_history/old_logs/*history
cd /var/log/user_history/old_logs
mv *gz /var/log/user_history/old_logs/02
[root@H99XXX bin]#
and a cronjob for it to run end of Feb:
Part B
[root@H99 bin]# crontab -l | grep user_history_Feb
01 22 29 2 * /usr/local/bin/user_history_Feb
[root@H99 bin]# uname -a
Linux H99 2.6.18-274.17.1.el5 #1 SMP Wed Jan 4 22:45:44 EST 2012 x86_6
+4 x86_64 x86_64 GNU/Linux
[root@H99 bin]#
I am using RHEL 5.7
I know my "script" is no script, and would be very thankful if someone could help me into scriptifying part A so I can adjust the cron
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.