Sponsored Content
Top Forums UNIX for Dummies Questions & Answers delete files that are over 2 hours old Post 23860 by flounder on Monday 1st of July 2002 12:06:56 PM
Old 07-01-2002
I know the date command when formatted with give you the time.

Example:

phdb102 [ogd] >date +%H:%M
12:02

This is the using variables in a shell script:

#!/usr/bin/ksh

the_hour=`date +"%H"`
the_min=`date +"%M"`
calc_time=`expr $the_hour - 2`
echo "The current time is $the_hour:$the_min"
echo "This is the calculated time $calc_time:$the_min"

The result:

phdb102 [ogd] >the_time.sh
The current time is 12:04
This is the calculated time 10:04

Knowing this I am not sure how to incorporate this into the find command. I will experiment and let you know what I come up with.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Finding files older than 2 hours

I want to write a sh script that will find files older than 2 hours and tar them. I've had a look at the find man page but can't see how to do it by hours. Help please. Thanx (1 Reply)
Discussion started by: ianf
1 Replies

2. Shell Programming and Scripting

move log files over 12 hours old...

Hi, I know I can use touch and find's "! -newer" option to list files that are older than a specific time, but what is a good way to get a list of files that are over 12 hours old? The log pruner will run throughout the day, twice an hour. So I can't easily use a cronjob touch command to generate... (1 Reply)
Discussion started by: Thomas Pluck
1 Replies

3. Shell Programming and Scripting

removing files after 6 hours or older

What is the command to remove files that are generated 6 hours or older? The find and remove tells only how to remove if the file is one day old or more. Appreciate quick reply. Thanks (3 Replies)
Discussion started by: gthokala
3 Replies

4. Shell Programming and Scripting

Files created in last 24 hours

I need a script which list the files which is starting with the word heap*** and that is created before past 24 hours.I need the script using find command. please help me on this. (1 Reply)
Discussion started by: jayaramanit
1 Replies

5. UNIX for Dummies Questions & Answers

Delete logs every 3 hours

Hi, I want to setup a cronjob that will delete logs every 2 hours. I have script that delete logs per day. but logging is too big and i want to run a conjob that will delete every 2 hours. this is my current command but it deletes on a per day basis. find . -name "*.log*" -o -name... (3 Replies)
Discussion started by: tungaw2004
3 Replies

6. Shell Programming and Scripting

How to find files by hours old?

I need to be able to do the following: Find files in multiple directories that are 6 hours older than the current time? I am using KSH I tried mmtime but it was not a valid option Any help would be great. Thank you! (2 Replies)
Discussion started by: llsmr777
2 Replies

7. Shell Programming and Scripting

how to list files between last 6 hours to 3 hours

Hi Frens, I want to list some files from a directory, which contains "DONE" in their name, i am receiving files every minute. In this i want to list all the files which are newer than 6 hours but older than 3 hours, of current time i dont want my list to contain the latest files which are ... (4 Replies)
Discussion started by: Prat007
4 Replies

8. Shell Programming and Scripting

files older than few hours

Hi All I need to know the command which can be used to list the files which are 3 hours old so that it can be deleted. (3 Replies)
Discussion started by: mskalyani9
3 Replies

9. Shell Programming and Scripting

ls files newer than 6 hours

How do I list al files in a folder with a creation date/time newer than 6 hours? (2 Replies)
Discussion started by: locoroco
2 Replies

10. Shell Programming and Scripting

Deleting Files Older than 1 hours.

How to Deleting Files Older than 1 hours. Base on SunOS. this file gen every 1 min. -rw-r--r-- 1 nobody nobody 4960 Jan 27 02:02 23_201301270201.log -rw-r--r-- 1 nobody amudu 2325 Jan 27 02:03 33_201301270202.log -rw-r--r-- 1 nobody amudu 3255 Jan 27 02:03... (2 Replies)
Discussion started by: ooilinlove
2 Replies
DATE_DEFAULT_TIMEZONE_SET(3)						 1					      DATE_DEFAULT_TIMEZONE_SET(3)

date_default_timezone_set - Sets the default timezone used by all date/time functions in a script

SYNOPSIS
bool date_default_timezone_set (string $timezone_identifier) DESCRIPTION
date_default_timezone_set(3) sets the default timezone used by all date/time functions. Note Since PHP 5.1.0 (when the date/time functions were rewritten), every call to a date/time function will generate a E_NOTICE if the timezone isn't valid, and/or a E_WARNING message if using the system settings or the $TZ environment variable. Instead of using this function to set the default timezone in your script, you can also use the INI setting date.timezone to set the default timezone. PARAMETERS
o $timezone_identifier - The timezone identifier, like UTC or Europe/Lisbon. The list of valid identifiers is available in the "List of Supported Time- zones". RETURN VALUES
This function returns FALSE if the $timezone_identifier isn't valid, or TRUE otherwise. EXAMPLES
Example #1 Getting the default timezone <?php date_default_timezone_set('America/Los_Angeles'); $script_tz = date_default_timezone_get(); if (strcmp($script_tz, ini_get('date.timezone'))){ echo 'Script timezone differs from ini-set timezone.'; } else { echo 'Script timezone and ini-set timezone match.'; } ?> CHANGELOG
+--------+---------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------------+ | 5.3.0 | | | | | | | Now throws E_WARNING rather than E_STRICT. | | | | | 5.1.2 | | | | | | | The function started to validate the $time- | | | zone_identifier parameter. | | | | +--------+---------------------------------------------------+ SEE ALSO
date_default_timezone_get(3), "List of Supported Timezones". PHP Documentation Group DATE_DEFAULT_TIMEZONE_SET(3)
All times are GMT -4. The time now is 09:28 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy