Schedule script to run.

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
timhatz
Posts: 41
Joined: 12 Dec 2008 06:21

Schedule script to run.

Post 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

admin
Site Admin
Posts: 60357
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Schedule script to run.

Post by admin »

Not implemented. Maybe later I can add a switch /load=[xys file]...

PeterH
Posts: 2776
Joined: 21 Nov 2005 20:39
Location: Germany

Re: Schedule script to run.

Post 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.)

admin
Site Admin
Posts: 60357
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Schedule script to run.

Post 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.

timhatz
Posts: 41
Joined: 12 Dec 2008 06:21

Re: Schedule script to run.

Post 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

admin
Site Admin
Posts: 60357
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Schedule script to run.

Post 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?

timhatz
Posts: 41
Joined: 12 Dec 2008 06:21

Re: Schedule script to run.

Post 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

admin
Site Admin
Posts: 60357
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Schedule script to run.

Post 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.

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Re: Schedule script to run.

Post 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';
Proud XYplorer Fanatic

aimy
Posts: 181
Joined: 26 Feb 2007 15:44

Re: Schedule script to run.

Post by aimy »

Yeah would like to have this as well for backup purposes.

Anyone?

Thank you.

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Schedule script to run.

Post 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.
One of my scripts helped you out? Please donate via Paypal

aimy
Posts: 181
Joined: 26 Feb 2007 15:44

Re: Schedule script to run.

Post by aimy »

I've already had a program that could handle schedule.

Is there any chance that I could do this?

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Schedule script to run.

Post by highend »

Do what?
One of my scripts helped you out? Please donate via Paypal

aimy
Posts: 181
Joined: 26 Feb 2007 15:44

Re: Schedule script to run.

Post by aimy »

Do a schedule with a script file.

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Schedule script to run.

Post by highend »

Yeah, why not?

Write your backup script, but the call to it in the task planner (with a schedule). Done...
One of my scripts helped you out? Please donate via Paypal

Post Reply