×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Date Manipulation / Cron Job

Date Manipulation / Cron Job

Date Manipulation / Cron Job

(OP)
Greetings:

I don't have the ability to install new modules on my ISP's server
(running Perl 5.05), and they are a bit sticky about such things.  So, I
was wondering if any of you might be able to help me with a code
snippet.   The problem is as follows:

1)  I want to execute a function to clean up my database every other
Monday.  I can easily have my ISP institute a cron job on the server to
kick off my Perl script that cleans the database, but the problem with
cron is that it can only be told to run every Monday.

2)  When my Perl script executes every Monday, I want to have some code
in it to check and see if this is an even or odd Monday and either exit
or perform the functions for cleaning the database.  Does anybody have
any code snippets or references for how I might check the date, and then
determine if this is the Monday that I want to execute the database
cleaning functions?

Thanks,

Mark

RE: Date Manipulation / Cron Job

perldoc -f localtime

will give you all of the info you need on the date functino, that's pretty simple to find out...

As always, I hope that helped!

Disclaimer:
Beware: Studies have shown that research causes cancer in lab rats.

RE: Date Manipulation / Cron Job

For more info, check out hte FAQ in this section on getting help (It's on the tab at the top of the page) or see hmerril's tip post below.

MWB

As always, I hope that helped!

Disclaimer:
Beware: Studies have shown that research causes cancer in lab rats.

RE: Date Manipulation / Cron Job

You could write a flag to your database or filesystem.  The first time you set it to 0 and run your functions.  The next monday, set it to 1 and exit.  The next monday, set it to 0 and run your functions, etc.

You could try to do it by date, but that will have problems since you have to deal with daylight savings, leap years, etc.  Let cron handle that stuff, that's what it was built for.


Sincerely,
 
Tom Anderson
CEO, Order amid Chaos, Inc.
http://www.oac-design.com

RE: Date Manipulation / Cron Job

Well, you could also have a small text file consisting of one integer, and you could set it to 1 the first Monday, 0 the next, 1 the next, and so on and so forth.  I think that's what tom means, right?

As always, I hope that helped!

Disclaimer:
Beware: Studies have shown that research causes cancer in lab rats.

RE: Date Manipulation / Cron Job

Yeah, that's what I said.


Sincerely,
 
Tom Anderson
CEO, Order amid Chaos, Inc.
http://www.oac-design.com

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close