Welcome, Guest. Please login or register.
Did you miss your activation email?


Login with username, password and session length

Search

 
Advanced search

8043 Posts in 1856 Topics- by 2099 Members - Latest Member: roi
Pages: [1]   Go Down
Print
Author Topic: DeleteOld and Cron  (Read 704 times)
0 Members and 1 Guest are viewing this topic.
kmcpeak
New Member
*

Karma: 0
Offline Offline

Posts: 0

Wed Developer


WWW
« on: January 18, 2005, 08:39:00 AM »

I'm would like to run the DeleteOld plugin every day via a cronjob. So far I've figured out that http://preview.naturemuseum.org/cgi-bin/calendar_admin.pl?command=delete_old  is the url I need to implement into the cron. But when I do this I receive the below error because the DeleteOld plugin is looking for a date:

Error running custom function 'command_delete_old'. The error is: [Month '-1' out of range 0..11 at /home/naturepr/wwwroot/preview.naturemuseum.org/cgi-bin/calendarscript/lib/TimeLocal.inc line 57. ]

Is it possible to modify the DeleteOld plugin so that if no date is given it defaults to the current time?

Any help is much appreciated.

thanks,
Kevin McPeak

Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 230

Please don't PM me. Post in the open forum.


WWW
« Reply #1 on: January 18, 2005, 03:58:00 PM »

In command_delete_old.pl you can try changing the line:

my $deldate = $in{DELETEDATE};

to

my ($ss,$mi,$hh,$dd,$mm,$yy,$wd,$yd,$dst) = localtime(time+$localtime_offset);
$month = &LZ($mm+1);
$year = $yy+1900;
$date = &LZ($dd);

$current_date = $year.$month.$date;

my $deldate = $in{DELETEDATE} | | $current_date;

 This forum adds a space between | |. Make sure you remove that added space.

 This is untested so use at your own risk. Always keep a backup or original files.

Dan O.

------------------

Logged
kmcpeak
New Member
*

Karma: 0
Offline Offline

Posts: 0

Wed Developer


WWW
« Reply #2 on: January 19, 2005, 12:30:00 PM »

Dan thanks for the help, when I implemented your modification I recieved the following error:

Error running custom function 'command_delete_old'. The error is: [Undefined subroutine &main::LZ called at /home/naturepr/wwwroot/preview.naturemuseum.org/cgi-bin/calendarscript/plugins/DeleteOld/command_delete_old.pl line 13. ]

Line #13 in my script is:
$month = &LZ($mm+1);

Thanks again for your help,
kevin

------------------

Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 230

Please don't PM me. Post in the open forum.


WWW
« Reply #3 on: January 19, 2005, 01:00:00 PM »

Try adding the following between the last } and the 1; in that file:

sub LZ { my($x)=shift;if(length($x)==1){return "0$x";}return $x; }

Dan O.

------------------

Logged
kmcpeak
New Member
*

Karma: 0
Offline Offline

Posts: 0

Wed Developer


WWW
« Reply #4 on: January 19, 2005, 01:25:00 PM »

Dan I added that piece of code where you suggested and I don't get the error but when I run http://preview.naturemuseum.org/cgi-bin/calendar_admin.pl?command=delete_old  the browser refreshes but the events prior to today are not deleted.

If I use the deleteOld form though at: http://preview.naturemuseum.org/cgi-bin/calendar_admin.pl?template=delete_old.html  and select a date then this will work and the old events will get deleted.

So this is strange?

thanks,
kevin

Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 230

Please don't PM me. Post in the open forum.


WWW
« Reply #5 on: January 21, 2005, 07:13:00 PM »

I'm afraid I don't know what might be going on without doing some actual testing on the code being used.

However, if you just want to reset all the calendar's events at some point each day, setting up a cron job to just copy a blank set of event and schedule data files into the appropriate directory might be easier to accomplish?

Just a thought.

Dan O.

[This message has been edited by DanO (edited January 22, 2005).]

Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 230

Please don't PM me. Post in the open forum.


WWW
« Reply #6 on: January 21, 2005, 07:28:00 PM »

I just did a quick look at the command_delete_old.pl file and it looks like it is expecting other information to be passed too, like at least the calendar key(s) the events are to be deleted from.

If you're going to call it directly, you're going to have to include ALL the data that the template form would normally send.

BTW. Most administration functions won't work unless the user is logged in. I don't know if that particular function is the same.

JFYI

Dan O.

[This message has been edited by DanO (edited January 21, 2005).]

Logged
kmcpeak
New Member
*

Karma: 0
Offline Offline

Posts: 0

Wed Developer


WWW
« Reply #7 on: January 22, 2005, 10:53:00 PM »

Thanks again Dan for your thoughts. My end goal with setting a cronjob to run DeleteOld every night at midnight is to show the current day at the top of the list for the Month view. Month view is the default view for my calendar and I would like the current day to show up first in the list rather than the first of the month. I know that if I delete all events prior to today than the calendar will display this way. But if you can suggest another way of doing this I'd be happy to do it that way as well. Especially since it doesn't seem like using a CronJob to run DeleteOld is going to work.

thanks again,
kevin

Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 230

Please don't PM me. Post in the open forum.


WWW
« Reply #8 on: January 23, 2005, 04:41:00 PM »

** But if you can suggest another way of doing this  **

*I* would likey either modify the default.html template file to add a different view to be used as the default  which skips the printing of past events or set up the default view to use a set period of time like today forward as the SSI template does.

JMO

Dan O.

------------------

Logged
Pages: [1]   Go Up
Print
Jump to: