AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

iam searchnig for simple CRON command

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Wish List
View previous topic :: View next topic  
Author Message
Stefan



Joined: 30 Jul 2004
Posts: 72
Location: Deutschland (sorry for my english)

PostPosted: Tue Oct 19, 2004 5:50 pm    Post subject: iam searchnig for simple CRON command Reply with quote

Hi Chris,

i searched the AHK help for an simple cron syntax.
Is there any?



Like:
AHKCron, <Minute> <Hour> <Day> <Month> <Day of Week> <Command line>

e.g.
AHKCron, 0 2 * 1-11 1-5 MsgBox, Coffee break


---
or e.g.

# start a backup every tuesday at midnight
AHKCron 0 0 * * 3 c:\tests\backup.bat



Is there such a simple syntax, i need a keyword to find this in the help.

Is this not, i wanna suggest this as new feature to use AHK as CRON.
I think about an "AHKCron.ahk" script file, containing those AHKCron commands.

THX
Stefan
_________________
Stefan

This post was created with the kindly help of http://dict.leo.org/ and remember: “Allways look on the bright side of Life”
Back to top
View user's profile Send private message
Nemroth



Joined: 07 Sep 2004
Posts: 262
Location: France

PostPosted: Tue Oct 19, 2004 6:42 pm    Post subject: Reply with quote

I'm OK with this proposition.

Perhaps it would be better to have :

AHKCron, Day, Month, Year, Hour, Minute, Seconds, Command line

and/or

AHKCron, +Minutes, Command line

where "+Minutes" stand for the number of minutes after the lauch of the ahk script or of the compiled exe script.
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10471

PostPosted: Tue Oct 19, 2004 7:15 pm    Post subject: Reply with quote

That's on the to-do list as "Add scheduling by extending SetTimer, e.g. daily at a certain time, etc."

I have raised its priority and made a note of your ideas for when the time comes. Thanks.

In the meantime, you could use the built-in date-time math along with SetTimer to schedule something:
Code:
#persistent

TargetTime = 1400  ; run at 2pm, which is 1400.

StringLeft, TargetDateTime, A_Now, 8  ; Put just YYYYMMDD into the variable.
TargetDateTime = %TargetDateTime%%TargetTime%
TimeUntilTarget = %TargetDateTime%
TimeUntilTarget -= %A_Now%, seconds
if TimeUntilTarget < 0
{
     MsgBox The target time is already past!
     ExitApp
}
TimeUntilTarget *= 1000 ; Convert to milliseconds.
SetTimer, Timer1, %TimeUntilTarget%
return

Timer1:
SetTimer, Timer1, off  ; i.e. perform this subroutine only once.
; In case you want to be warned before it happens, in case it changes the
; active window or otherwise disrupts what the user is working on:
SplashTexton,,, It's about to happen.
Sleep, 3000
SplashTextOff
; And here perform whatever action you wanted scheduled:
; ...
return


Last edited by Chris on Tue Jun 28, 2005 8:14 am; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail
Nemroth



Joined: 07 Sep 2004
Posts: 262
Location: France

PostPosted: Tue Oct 19, 2004 7:38 pm    Post subject: Reply with quote

Very interesting code.
I'll keep waiting for a Cron command in AHK in the future.
Thanks Chris.
Back to top
View user's profile Send private message
Stefan



Joined: 30 Jul 2004
Posts: 72
Location: Deutschland (sorry for my english)

PostPosted: Tue Oct 19, 2004 9:49 pm    Post subject: Reply with quote

Thanks for the answer.
Thanks for raised its priority too.


-----------------------------------------------.
Nemroth wrotes:
> Perhaps it would be better to have :
> AHKCron, Day, Month, Year, Hour, Minute, Seconds, Command line

No, i suggest highly to use the well famliliar and well testet UNIX syntax of cron.
AHKCron <Minute> <Hour> <Day_of_the_Month> <Month_of_the_Year> <Day_of_the_Week> <command>

* * * * *
| | | | |
| | | | |
| | | | +---- Day of the Week (range: 1-7, 1 standing for Monday)
| | | +------ Month of the Year (range: 1-12)
| | +-------- Day of the Month (range: 1-31)
| +---------- Hour (range: 0-23)
+------------ Minute (range: 0-59)

<command> could be an *.exe, *.com, *.bat, *cmd, *.vbs, *.ahk ... ,
or directly an AHK command or an AHK variable who will be found
as a part of a bigger script at the end of the AHKCron.ahk file.

Click here for syntax and examples
If you need more details, let me here pls!!!

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

Further more i suggest additional commands:

1) The char +, who means execute <command> 'n' minutes or seconds
or days after windows start, depending on the position of the '+' in
command line. (THX Nemroth for this very nice idea)

2) a sixt row * for the year (like nnCron)

3) a sevent row for this following chars:
   char ?, who means execute <command> during windows start.
    char #, who means execute <command> on windows shutdown (not on cancling the script).


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

> In the meantime,
Thanks for pointing me to this script.
_________________
Stefan

This post was created with the kindly help of http://dict.leo.org/ and remember: “Allways look on the bright side of Life”
Back to top
View user's profile Send private message
savage



Joined: 02 Jul 2004
Posts: 206

PostPosted: Mon Oct 25, 2004 10:59 pm    Post subject: Reply with quote

Quote:
Nemroth wrotes:
> Perhaps it would be better to have :
> AHKCron, Day, Month, Year, Hour, Minute, Seconds, Command line

No, i suggest highly to use the well famliliar and well testet UNIX syntax of cron.


I think nemroth's idea is probably the most appropriate. You have to consider the fact that AHK is all about simplicity and Nemroth's is certainly simpler and more natural. Also, I'm not sure how many of AHK's users would be familiar with UNIXen at all, and of those, how many of them actually know and use cron.

That being said, scheduling support would certainly be good.
Back to top
View user's profile Send private message AIM Address
Wingfat



Joined: 23 Aug 2004
Posts: 193
Location: East Bay, California USA

PostPosted: Mon Oct 25, 2004 11:18 pm    Post subject: Reply with quote

I am useing the built in Windows Scheduler myself. I can get it to launch complied AHK scripts when I need them to. Built in function would be nice, but in essence not very necessary for most users applications.
Back to top
View user's profile Send private message
robertus
Guest





PostPosted: Tue Jan 25, 2005 9:46 pm    Post subject: Reply with quote

maybe you should think about introducing a bit more than just cron.
I am familiar with a shareware called "Macro Angel" which has good scheduling features (but some of the macro stuff sucks) - when you worked with that you know there is more to it than just a cron-command:
for example what should happen to the script when it failed - should it be rescheduled for next week, or disabled?

Also the scheduler should log when the script was execute in the past (plus results?). for example: a script that is due every monday and you turn on your computer and it is tuesday and the day before you had a holiday. There should be a feature saying: test if the script is/was due. if it is overdue:
a.) run it right away and reschedule it for next monday (tuesday?)
b.) ask what to do
c.) don't bother just wait for next monday
Back to top
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10471

PostPosted: Tue Jan 25, 2005 10:44 pm    Post subject: Reply with quote

Thanks for the ideas. I've made a note to review them again when the time comes to work on this feature.
Back to top
View user's profile Send private message Send e-mail
Guest






PostPosted: Thu Feb 03, 2005 2:42 am    Post subject: my two cents worth Reply with quote

The time should be in the already establisted format used by other commands...

The elements of the YYYYMMDDHH24MISS format are:

YYYY The 4-digit year
MM The 2-digit month (01-12)
DD The 2-digit day of the month (01-31)
HH24 The 2-digit hour in 24-hour format (00-23) e.g. 09 is 9am, 21 is 9pm
MI The 2-digit minutes (00-59)
SS The 2-digit seconds (00-59)

If only a partial string is given for YYYYMMDDHH24MISS (e.g. 200403), any remaining element that has been omitted will be supplied with the following default values:

MM: Month 01
DD: Day 01
HH24: Hour 00
MI: Minute 00
SS: Second 00

The built-in variable A_Now contains the current local time in the above format.
Back to top
Stefan



Joined: 30 Jul 2004
Posts: 72
Location: Deutschland (sorry for my english)

PostPosted: Fri Aug 24, 2007 11:45 am    Post subject: Reply with quote

Hi Chris,
are there any news about an intern cron functionality?
This would be quit simpler then Timer / Sleep / IFs

Code:
#SingleInstance force
;every two working hours on Mo-Fr

CRON * 10,12,14,16 * * 1-5
(
MsgBox What have you done till now?
Run worksheet.xls
some AHK code here
)

Return



Reminder:
> Chris Posted: Tue Oct 19, 2004 9:15 pm
> That's on the to-do list as "Add scheduling by extending SetTimer,
> e.g. daily at a certain time, etc."



Thanks
_________________
Stefan

This post was created with the kindly help of http://dict.leo.org/ and remember: “Allways look on the bright side of Life”
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10471

PostPosted: Mon Aug 27, 2007 10:46 pm    Post subject: Reply with quote

Yes, it's still planned. I consider scheduling to be a pretty big benefit that would be used by quite a few people.
Back to top
View user's profile Send private message Send e-mail
tonne



Joined: 06 Jun 2006
Posts: 1249
Location: Denmark

PostPosted: Tue Aug 28, 2007 6:32 am    Post subject: Reply with quote

FYI
I am currently working on a script offering cron capabilities.
It will be packeted in two parts: a library and a standalone interface using the library.
I hope the library will be ready in the end of this week (ultimo august 07 Wink). The interface some weeks later.

EDIT:
The first beta version is out: http://www.autohotkey.com/forum/viewtopic.php?p=143772#143772
_________________
there's a dog barking close within the range of my ear
sounds like he wants to escape the chain
he would probably bite me to death if he could
but the chain lets me spit in his face

- Kashmir
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Wish List All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group