RE: A unix cron job question

  • From: Øyvind Lode <oyvind.lode@xxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Wed, 30 Jun 2010 22:04:46 +0200

Php is mainly used as a server side web language.
But it's also used at the command line, though rarely.
To see if the php interpreter is installed execute the following command:

Which php

If the php command line interpreter is installed it will provide the path to
the executable.
If it's not installed you'll get a message like "no php in path" or "command
not found".

-----Original Message-----
From: programmingblind-bounce@xxxxxxxxxxxxx
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Lafond, Eileen
Sent: 30. juni 2010 20:30
To: programmingblind@xxxxxxxxxxxxx
Subject: RE: A unix cron job question

How would I know if we have php here?  All the unix I know I have learned on
my own and I haven't had any training so this might sound like a stupid
question.
Thanks,

Eileen La Fond



-----Original Message-----
From: programmingblind-bounce@xxxxxxxxxxxxx
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Humberto
Rodriguez
Sent: Friday, June 25, 2010 5:43 PM
To: programmingblind@xxxxxxxxxxxxx
Subject: Re: A unix cron job question

Probably the easiest way is to use PHP and the seconds from the Unix Epoch 
(Jan 1, 1970 GMT).  To go back 30 days, you may do:

$now= date("U");
$then= $now - (60*60*24*30);

Then, if you want the ISO-8601 date:
$date= date("c", $now);

For the RFC-2822 date:
$date= date("r", $now);

There are many more formats for getting the date and time anyway you want, 
all the Unix choices.  Look at the function date() in php.net.

HIH,

Humberto

----- Original Message ----- 
From: "Lafond, Eileen" <Eileen.Lafond@xxxxxxxxxxx>
To: <programmingblind@xxxxxxxxxxxxx>
Sent: Friday, June 25, 2010 6:29 PM
Subject: A unix cron job question


We run many cron jobs daily that create a log file per cron job.  This 
creates many log files over time.  I think that we have about 33000 files 
right now.

I am trying to create a cron job that will run once a month and delete all 
the log files that are more than thirty days out.

I am trying now just to put the specification document together and I am 
having a difficult time with the details of the code.

I was thinking of using the following:

mydate="`date +"%m%d%y%H%M""

I cannot figure out how to write the code to go thirty days back and when I 
get that, I will then create a delete statement to delete the rest of the 
files.

Does anyone have any idea as to how I can use the mydate above to figure out

thirty days bac?

Or am I doing this the wrong way and there might be an easier way to do it?



Thanks for any help.

Eileen La Fond
Work Phone: (206) 386-0011
Email: Eileen.lafond@xxxxxxxxxxx

__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind


__________
View the list's information and change your settings at 
//www.freelists.org/list/programmingblind

__________
View the list's information and change your settings at 
//www.freelists.org/list/programmingblind


__________
View the list's information and change your settings at 
//www.freelists.org/list/programmingblind

Other related posts: