Page 1 of 1
Schedule script to run.
Posted: 18 Sep 2009 22:54
by timhatz
I would like a script to run at a certain time of the day. I assume, I need to have my scheduler call xyplorer with command line switches, but what command line switch do I use to indicate the script to run, once its launched, and then have it close down the instance after the script has finished?
Thanks, Tim
Re: Schedule script to run.
Posted: 19 Sep 2009 09:43
by admin
Not implemented. Maybe later I can add a switch /load=[xys file]...
Re: Schedule script to run.
Posted: 20 Sep 2009 10:08
by PeterH
admin wrote:Not implemented. Maybe later I can add a switch /load=[xys file]...
Shouldn't it be called /exec= or /script= to better show what it's for?
And didn't we talk about an initial script? Then calling xy with a .ini containing an initial script could achieve the same.
(But I think both could be helpful.)
Re: Schedule script to run.
Posted: 21 Sep 2009 15:49
by admin
PeterH wrote:admin wrote:Not implemented. Maybe later I can add a switch /load=[xys file]...
Shouldn't it be called /exec= or /script= to better show what it's for?
And didn't we talk about an initial script? Then calling xy with a .ini containing an initial script could achieve the same.
(But I think both could be helpful.)
Yes, /script= looks good.
Initial could be handled as CEA (on event "startup": load script...) in future.
Re: Schedule script to run.
Posted: 22 Sep 2009 20:08
by timhatz
It would be nice to have another switch to tell the system to not show the gui, so it just stays hidden while it executes, and then unloads from memory nicely when the script finishes.
tim
Re: Schedule script to run.
Posted: 22 Sep 2009 20:25
by admin
timhatz wrote:It would be nice to have another switch to tell the system to not show the gui, so it just stays hidden while it executes, and then unloads from memory nicely when the script finishes.
tim
Just curious: what kind of script is that? Backup?
Re: Schedule script to run.
Posted: 23 Sep 2009 02:22
by timhatz
For an example it would be nice to automate the delete of files older than 10 days in a folder based on a filter.
Without having to run it manually.
Tim
Re: Schedule script to run.
Posted: 23 Sep 2009 09:00
by admin
timhatz wrote:For an example it would be nice to automate the delete of files older than 10 days in a folder based on a filter.
Without having to run it manually.
I see. I'm not very fond of this kind of automatic stuff. Too dangerous, too robotic. Think of freaking robots in science fiction...
But, with a little effort, you could do it with scripting: A script that runs a number of other scripts once per day. So all you'd have to do is press a button once, and then all your daily one-time routines would be performed. If you press again, the button would know (INI storage) that he did the job already today and do nothing. The later, if we have CEA, you could tie this button to any event (e.g. startup). That way, using XY (and triggering that event) would ensure the jobs get done.
Re: Schedule script to run.
Posted: 23 Sep 2009 12:07
by jacky
admin wrote:But, with a little effort, you could do it with scripting: A script that runs a number of other scripts once per day. So all you'd have to do is press a button once, and then all your daily one-time routines would be performed. If you press again, the button would know (INI storage) that he did the job already today and do nothing. The later, if we have CEA, you could tie this button to any event (e.g. startup). That way, using XY (and triggering that event) would ensure the jobs get done.
Just for the example, I do have something like that myself (Note: this is a simple copy/paste, I haven't had the time to use the "new" loops/etc) :
Code: Select all
"Do cron jobs : doCron"
global $CRON_list;
sub _ensureXY;
self $base, base;
$today = <date dd/mm/yyyy>;
getkey $lastrun, "LastRun", "Settings", "$base.ini";
// if we already ran today, we stop here
end ($lastrun == $today),,1;
status "Processing cron jobs for today ($today)...",,progress;
getkey $CRON_list, "list", "Jobs", "$base.ini";
$CRON_list = "$CRON_list,";
// adds a last coma to make things easier to work with on loop
setting "AllowRecursion", 1;
sub ($CRON_list != ",") ? "_cronLoop" : "_nothing";
setting "AllowRecursion", r;
//
// done for today!
setkey $today, "LastRun", "Settings", "$base.ini";
status "Cron jobs for today ($today) completed";
"_cronLoop"
global $CRON_list;
self $base, base;
// "extracts" first element on list
strpos $p, $CRON_list, ",";
substr $id, $CRON_list, 0, $p;
substr $CRON_list, $CRON_list, $p + 1;
//
// get definition of the cron job, and run it if condition evaluates to true -- simple as that!
getkey $condition, "Condition$id", "Jobs", "$base.ini";
getkey $script, "Script$id", "Jobs", "$base.ini";
load (eval($condition) ? $script : 'call'),,s;
//
end ($CRON_list == ""),,1;
sub _cronLoop;
Using an INI file such as this:
Code: Select all
[Settings]
LastRun=23/09/2009
[Jobs]
list=1,2
Condition1=1
Script1=load 'dailyScript';
Condition2=<date w> == 2
Script2=load 'weeklyScript';
Re: Schedule script to run.
Posted: 09 Sep 2014 07:16
by aimy
Yeah would like to have this as well for backup purposes.
Anyone?
Thank you.
Re: Schedule script to run.
Posted: 09 Sep 2014 07:49
by highend
Write a script that puts a call to your backup xys script into the windows task planner.
Use a second XY instance which shuts down after the script has ended.
Why? Because there is no way to examine if the main XY instance is currently running a script and feeding the backup script via /flg=2 into the main instance can fail because of this reason.
Re: Schedule script to run.
Posted: 09 Sep 2014 08:06
by aimy
I've already had a program that could handle schedule.
Is there any chance that I could do this?
Re: Schedule script to run.
Posted: 09 Sep 2014 08:16
by highend
Do what?
Re: Schedule script to run.
Posted: 09 Sep 2014 09:47
by aimy
Do a schedule with a script file.
Re: Schedule script to run.
Posted: 09 Sep 2014 09:50
by highend
Yeah, why not?
Write your backup script, but the call to it in the task planner (with a schedule). Done...