Sponsored Content
Full Discussion: Delete logs every 3 hours
Top Forums UNIX for Dummies Questions & Answers Delete logs every 3 hours Post 302149858 by fpmurphy on Saturday 8th of December 2007 09:17:26 AM
Old 12-08-2007
One way of doing it would be to set up a cron job that calls a shell script every hour.

Within the shell script, use the date utility to return the hour_of_the_day in 24 hr format. Test if (hour_of_the_day % 2) is zero. If so execute the remainder of the script, otherwise exit.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

delete files that are over 2 hours old

guys, I have a need for a script that will delete all files in a given directory that are over 2 hours old. I will set this up to run in cron. I'm having a little trouble coming up with the syntax that will identify these files. Is there a variation of the ls command that I can use to identify... (3 Replies)
Discussion started by: hedrict
3 Replies

2. Shell Programming and Scripting

I need to delete the content out of a number of logs

I'm just starting out in scripting (taking online classes) but I need to know how to clean out (delete) the content of a number of logs. All of the files end in 'trc'. Does anyone have a script or command (SED or AWK) I can use? Julie (4 Replies)
Discussion started by: Jbolin01
4 Replies

3. Shell Programming and Scripting

Delete old logs

Hello All, We have a directory where we have old archived logs. They are numbered <logfile>.log.1 till <logfile>.log.100 or more. I just want to keep 10 log files and delete others through the script. Please advise. Thanks, Chiru (4 Replies)
Discussion started by: chiru_h
4 Replies

4. UNIX for Dummies Questions & Answers

Delete last 10 days logs

Hi Can u please tell me how to delete last 10 days logs .. (9 Replies)
Discussion started by: pb18798
9 Replies

5. Shell Programming and Scripting

Retrieve logs for last 4 hours

Our log file looks like this: 2010-11-18 00:57:01,698 ERROR Shipment Error Log:Error Details - Account Id:3962, PO:2710015, Line:2, File:221112901, Version:V1, Desc:Order cannot not be shipped as there are no line items in New state 2010-11-18 14:59:39,960 ERROR... (11 Replies)
Discussion started by: Deepthz
11 Replies

6. Shell Programming and Scripting

Retrieve logs for previous 4 hours

Hi, I am in the process of configuring a script, and i intend it to retrieve logs for previous four hours, and then scan for predefined errors. I am kind of stuck on the log retrieval part where the script will run early morning like 1 AM or 2 AM, the command as posted below will give me... (4 Replies)
Discussion started by: john_prince
4 Replies

7. Shell Programming and Scripting

Command to clear logs for every 6 hours in solaris

Hi Folks, I need to remove log files for six hours on Solaris. before i used to do for every 24 hours below is the code for 1 day older log files, now i tried using -mmin +360 but it says command not found. Can someone please help me out!!! part of the code: LOG_FILE=`find /home/Logdir... (1 Reply)
Discussion started by: Sendhil.Kumaran
1 Replies

8. Shell Programming and Scripting

To delete logs older than 30 days

I want to write a shell script that deletes all log files in a directory that are older than 30 days except for 3 files: I am using the following command: find /tmp/logs -name "*.log" -mtime +30 -exec rm -f {} \;But this command deletes all the log files. How can i modify this script that... (5 Replies)
Discussion started by: mmunir
5 Replies

9. Shell Programming and Scripting

Delete logs older than 60 days

i am using HP-UX OS...... delete logs older than 60 days find -mtime +60 | grep -i '.*log' | xargs rm -mtime is nt available in HP-UX, pls tell me other option ? (2 Replies)
Discussion started by: only4satish
2 Replies

10. Shell Programming and Scripting

Script to compress and delete the older logs

Hello Guys, Can you please help me with a script which zips the older log files(1-2 weeks) and delete them? I want to run the script manually instead of setting it up in a cron job. Appreciate your help. Regards, Kris (6 Replies)
Discussion started by: kriss.gv
6 Replies
rotatelogs(8)						      System Manager's Manual						     rotatelogs(8)

NAME
rotatelogs - rotate Apache logs without having to kill the server SYNOPSIS
rotatelogs logfile rotationtime [offset] DESCRIPTION
rotatelogs is a simple program for use in conjunction with Apache's piped logfile feature, which can be used like this: CustomLog "|bin/rotatelogs /var/logs/logfile 86400" common This creates the files /var/logs/logfile.nnnn where nnnn is the system time at which the log nominally starts (this time will always be a multiple of the rotation time, so you can synchronize cron scripts with it). At the end of each rotation time (here after 24 hours) a new log is started. OPTIONS
logfile The path plus basename of the logfile. If logfile includes any Otherwise, the suffix .nnnnnnnnnn is automatically added and is the time in seconds. Both formats compute the start time from the beginning of the current period. rotationtime The rotation time in seconds. offset The number of minutes offset from UTC. If omitted, zero is assumed and UTC is used. For example, to use local time in the zone UTC -5 hours, specify a value of -300 for this argument. PORTABILITY
The following logfile format string substitutions should be supported by all strftime(3) implementations, see the strftime(3) man page for library-specific extensions. %A full weekday name (localized) %a 3-character weekday name (localized) %B full month name (localized) %b 3-character month name (localized) %c date and time (localized) %d 2-digit day of month %H 2-digit hour (24 hour clock) %I 2-digit hour (12 hour clock) %j 3-digit day of year %M 2-digit minute %m 2-digit month %p am/pm of 12 hour clock (localized) %S 2-digit second %U 2-digit week of year (Sunday first day of week) %W 2-digit week of year (Monday first day of week) %w 1-digit weekday (Sunday first day of week) %X time (localized) %x date (localized) %Y 4-digit year %y 2-digit year %Z time zone name %% literal `%' SEE ALSO
httpd(8) March 2001 rotatelogs(8)
All times are GMT -4. The time now is 05:57 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy