[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4688: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4690: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4691: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4692: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
Poco Forums • View topic - Compressing mailboxes automatically

Compressing mailboxes automatically

Scripting questions and ideas

Moderators: Eric, Tomas, robin, Michael

Compressing mailboxes automatically

Postby dskirk » Sun Apr 11, 2010 11:28 am

I am wanting to be able to set up a script or event whereby my mailboxes are compressed on a schedule, such as weekly. I tried setting up a simple script with the compressmailbox command and using the Tools>Events?Timed to establish the event. Using the menu, I selected the script to run and ticked the box to run once every week. However, I found that the script runs everytime I start Pocomail, although the next start date is computed correctly - but ignored. If I untick the 'repeat' box, the script doesn't run at all. Is this a bug, or am I misunderstanding timed events? One of the options is to run a script so I'm guessing it's a bug. Please advise.

Also, since my real goal is to run the compressmailbox command on a schedule, is there a script that can execute a command on a scheduled basis? That's my real objective, but I'm surprised that the timed event feature doesn't do it. Thanks,
david
dskirk
Drop-in Visitor
 
Posts: 13
Joined: Sat Feb 16, 2008 6:23 am
Location: New York State

Postby MarkB » Mon Apr 12, 2010 3:24 am

...is there a script that can execute a command on a scheduled basis?


I will address this bit. (Timer events appear to be functioning properly here -- Poco 4.8, Win7.) Scripts can be triggered
- by filter
- by events
- manually
- by a running script (CallExternal)
- by command line (poco.exe /r "My Script")

To schedule a script command, the best bet is Poco's own timer events, especially if you want your script to be triggered only while Poco is running. An alternative is Windows Task Scheduler or any similar scheduler/reminder program, especially if you want your script to be triggered regardless of whether Poco is already running. A third choice -- a distant third -- is to run a script at every startup (but hey, that would be a Poco Event) and have the script check a scheduler routine programmed in PocoScript. Ugh.
MarkB
Poco Enthusiast
 
Posts: 217
Joined: Mon Aug 09, 2004 1:31 am
Location: Canada

Postby MarkB » Mon Apr 12, 2010 3:30 am

Oops. My apologies. Regarding the time event: I get the same result as you -- when the interval is set to one week, the script runs every time Poco opens.
MarkB
Poco Enthusiast
 
Posts: 217
Joined: Mon Aug 09, 2004 1:31 am
Location: Canada

Postby Tomas » Mon Apr 12, 2010 12:40 pm

Thank you David for reporting it. Here's a simple script I created for David based on Archive Old Mail script, it presupposes the script filename being compressmailboxes2.poc :

Code: Select all
Set $inifile "compressmailboxes2.ini"
External $userdata1 "Compress mailboxes every: (days)" "7"
ImportVar $CompressionDate $inifile

AppendToFile True

    { Get today's date }
GetDate $TodayDate
   { Calculate the difference in days since last backup }
SubDays #diff $TodayDate $CompressionDate

    { Compare the difference to user setting }
if #diff > $userdata1 then PerformCompression
    {following handles when there is no value in CompressionDate variable ie. it's probably the first run}
if #diff < 0 then PerformCompression
    { Exit if the difference is not greater }
Exit

{perform compression and set the last compression date}
:PerformCompression
CompressMailbox "*"
Set $CompressionDate $TodayDate
ExportVar $CompressionDate $inifile
Tomas
Tomas
Pillar of the Community
 
Posts: 1418
Joined: Sun Jul 25, 2004 1:34 am

Postby MarkB » Mon Apr 12, 2010 10:17 pm

My proposal was to retain the OP's own one-line script
Code: Select all
CompressMailbox "*"

but launch it via Windows Task Scheduler
Code: Select all
C:\Program Files (x86)\Pocomail4\Poco.exe /r CompressAll

once a week, or at log-on, etc. Assuming the script is named CompressAll.poc.

That makes it a do-it-yourself project, as opposed to a do-it-for-me project. But your script is nice too.

Either way, the CompressMailbox "*" line must not run while Poco is downloading mail -- as it might, for example, with either method, if Poco is configured to check for mail on startup or on schedule.
MarkB
Poco Enthusiast
 
Posts: 217
Joined: Mon Aug 09, 2004 1:31 am
Location: Canada

Postby MarkB » Mon Apr 12, 2010 11:18 pm

After a second cup of coffee...
Owing to the reported explosiveness of the CompressMailbox command when it collides with the downloading of mail, I recommend that the method I outlined not be used and that Tomas's script be used only with a guarantee that the CompressMailbox line will never run while mail is downloading, either automatically or manually.
MarkB
Poco Enthusiast
 
Posts: 217
Joined: Mon Aug 09, 2004 1:31 am
Location: Canada

Postby dskirk » Tue Apr 13, 2010 11:46 pm

Thanks for the discussion and the help. Tomas's solution works great if set to run as an event at QUIT. That ensures it never interferes with downloading mail. It's great being able to come to this forum and go away with solutions. :)
david
dskirk
Drop-in Visitor
 
Posts: 13
Joined: Sat Feb 16, 2008 6:23 am
Location: New York State

Re: Compressing mailboxes automatically

Postby ShyWriter » Thu Apr 15, 2010 2:49 am

dskirk wrote:I am wanting to be able to set up a script or event whereby my mailboxes are compressed on a schedule, such as weekly. I tried setting up a simple script with the compressmailbox command and using the Tools>Events?Timed to establish the event. Using the menu, I selected the script to run and ticked the box to run once every week. However, I found that the script runs everytime I start Pocomail, although the next start date is computed correctly - but ignored. If I untick the 'repeat' box, the script doesn't run at all. Is this a bug, or am I misunderstanding timed events? One of the options is to run a script so I'm guessing it's a bug. Please advise.

Also, since my real goal is to run the compressmailbox command on a schedule, is there a script that can execute a command on a scheduled basis? That's my real objective, but I'm surprised that the timed event feature doesn't do it. Thanks,
david


My last impression was that with 4.8, mailboxes were automatically compressed when needed - no need to set up a script or do it manually.

Shy
Feel free to add 781 posts to the number of posts shown by my avatar.. ;)
ShyWriter
Poco Tourist
 
Posts: 48
Joined: Mon Jul 26, 2004 2:33 pm

Re: Compressing mailboxes automatically

Postby Tomas » Fri Apr 16, 2010 1:24 am

Thanks Mark for the reminder about CompressMailbox quirks.

ShyWriter wrote:My last impression was that with 4.8, mailboxes were automatically compressed when needed - no need to set up a script or do it manually.


That's true ever since Pocomail was released I believe. I forgot the reasons (except one, someone said they don't like wasting the time waiting for automatic compression to happen, as it of course starts when they want to use Pocomail - when folder is entered - that's why choose to overcome automatic compression by running compression at the time when it doesn't disturb them) they shared with me but there are more users who have the need to compress folders on their own.
Tomas
Tomas
Pillar of the Community
 
Posts: 1418
Joined: Sun Jul 25, 2004 1:34 am

Re: Compressing mailboxes automatically

Postby ShyWriter » Fri Apr 16, 2010 2:46 am

Tomas wrote:Thanks Mark for the reminder about CompressMailbox quirks.

ShyWriter wrote:My last impression was that with 4.8, mailboxes were automatically compressed when needed - no need to set up a script or do it manually.


That's true ever since Pocomail was released I believe.[...]


Actually, auto-compression has NOT been around since day one. In fact, in many of the earlier releases, every time a person had a weird problem with POCO, one of the first things always suggested by us in fixing the problem was, "Compress your mailboxes." That fixed many a problem. :)

Shy
Feel free to add 781 posts to the number of posts shown by my avatar.. ;)
ShyWriter
Poco Tourist
 
Posts: 48
Joined: Mon Jul 26, 2004 2:33 pm


Return to PocoScript Help and How-To

Who is online

Users browsing this forum: No registered users and 1 guest

cron