Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

script for activity log

Status
Not open for further replies.

visvid

Technical User
Jun 3, 2002
131
GB
Wonder if anyone can help ?

Been asked by one of my customers to create a script to do the following:


a script to copy the activity.log to activity.log.old on the 1st of every month and create a new log for the current proceesses to write to.

I am not a script writer, so any help would be gratefully appreciated


Cheers

visvid
 
Visvid:

There's any number of ways to do this rather simple job. Here's mine:

#!/bin/ksh

# nullactivity.ss: cd to the directory where the activity log is
# and set umask to make new activity log read/write for everyone.
# mv the acitivity log to a back up with a date extension and finally
# create a new activity log
cd totheactivitylogdir
umask 000 # file is read/write for everybody
mv activity.log activity.log.old.`date '+%m%d%y'`
> activity.log # null or 0 length file
# end script

If you want to run this on the first of the month, create an entry in cron. The following line in the cron:

0 3 1 * * nullactiivity.ss

runs the job at 0300 on the first of every month. If you don't know how to set the cron, let me know and I'll post something.

Regards,


Ed
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top