Logic Machine Forum
Code to control scheduled script - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Code to control scheduled script (/showthread.php?tid=2250)



Code to control scheduled script - Mirco - 23.09.2019

Hi, now it's been an hour that I am searcing in the forum, but I' was not able to find what I need.

I would like to:
  1. Create a scheduled script and set all parameters: name, hour and minute, day, month, day of week, active/not active, category and description
  2. Modify a scheduled script and set all parameters: name, hour and minute, day, month, day of week, active/not active, category and description
  3. Delete a scheduled script
someone can answer with all this codes so that we have one thread with all the codes for control scripts?

Thank you very much! Smile


RE: Code to control scheduled script - Mirco - 25.09.2019

No one that can answer?? I have extremely and urgently need for a customer, please


RE: Code to control scheduled script - admin - 25.09.2019

Please explain what kind of task do you have. Sometimes there are better solutions but for that a more detailed description is needed.

Why can't you use built-in schedulers for this? Or you can create a scheduled script that runs every minute and handles task execution.


RE: Code to control scheduled script - Mirco - 25.09.2019

I have created a page were the user can modify 4 time slots, with hour and minute of star and end, and select the days of the week of working (I attached a picture)

So, when the user change something I need to change the start of the script, and if he deselect all days, I need to eliminate the script

I hope I explained correctly


RE: Code to control scheduled script - admin - 25.09.2019

Here is an example of how to create script from another one: https://forum.logicmachine.net/showthread.php?tid=1829&pid=11501#pid11501

For scheduled scripts params field must be in CRON format.


RE: Code to control scheduled script - Mirco - 25.09.2019

(25.09.2019, 07:26)admin Wrote: Here is an example of how to create script from another one: https://forum.logicmachine.net/showthread.php?tid=1829&pid=11501#pid11501

For scheduled scripts params field must be in CRON format.
Thanks,

Now I need to change hours, minutes, day of week of an existing scheduled script from a script.
Can you help me please?

Thanks! Smile


RE: Code to control scheduled script - Daniel - 25.09.2019

https://support.acquia.com/hc/en-us/articles/360004224494-Cron-time-string-format


RE: Code to control scheduled script - Mirco - 25.09.2019

(25.09.2019, 13:00)Daniel. Wrote: https://support.acquia.com/hc/en-us/articles/360004224494-Cron-time-string-format
Thanks, but it is not what I asked..

I don't know the code to modify an existing scheduled script from another script


RE: Code to control scheduled script - Daniel - 25.09.2019

I assume that when you run the same script again with different CRON settings it will update it.


RE: Code to control scheduled script - Mirco - 25.09.2019

I don't think because first it use a condition that it insert only if the script does not exist..


RE: Code to control scheduled script - Daniel - 25.09.2019

Then I would guess if you change to
if exists then
db:update('scripting', data)
it might work, make yourself a backup as this might screw things. I'm guessing Smile


RE: Code to control scheduled script - admin - 26.09.2019

Change params and id as needed, you can also update script by name instead of id: { name = 'my script name' }
Code:
db:update('scripting', { params = '* * * * *' }, { id = 123 })
script.reload(true)



RE: Code to control scheduled script - Mirco - 26.09.2019

Thank you very much! it works perfectly! Smile