This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Code to control scheduled script
#1
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
Reply
#2
No one that can answer?? I have extremely and urgently need for a customer, please
Reply
#3
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.
Reply
#4
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

Attached Files Thumbnail(s)
   
Reply
#5
Here is an example of how to create script from another one: https://forum.logicmachine.net/showthrea...1#pid11501

For scheduled scripts params field must be in CRON format.
Reply
#6
(25.09.2019, 07:26)admin Wrote: Here is an example of how to create script from another one: https://forum.logicmachine.net/showthrea...1#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
Reply
#7
https://support.acquia.com/hc/en-us/arti...ing-format
------------------------------
Ctrl+F5
Reply
#8
(25.09.2019, 13:00)Daniel. Wrote: https://support.acquia.com/hc/en-us/arti...ing-format
Thanks, but it is not what I asked..

I don't know the code to modify an existing scheduled script from another script
Reply
#9
I assume that when you run the same script again with different CRON settings it will update it.
------------------------------
Ctrl+F5
Reply
#10
I don't think because first it use a condition that it insert only if the script does not exist..
Reply
#11
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
------------------------------
Ctrl+F5
Reply
#12
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)
Reply
#13
Thank you very much! it works perfectly! Smile
Reply


Forum Jump: