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.

Stop a running script
#1
Hi

I have some system-scripts that takes several minutes to run. These are only ran by pressing the run button, so I have some control over when they are running.

But sometimes it would be good to be able to stop a script that is already running for some reason. Is this possible?
There are 10 kinds of people in the world; those who can read binary and those who don't  Cool
Reply
#2
Open scripting editor and get your script id (editor?id=123). Use this script to stop a running script with a certain id.
Code:
id = 123
os.execute('pkill -f "scripting-event.lua ' .. id .. ' "')
Note that this will work only for event scripts. For resident scripts use script.disable(script_name)
Reply
#3
How can I get script id in script? Is it some function available or I must get it from db?
Done is better than perfect
Reply
#4
(09.11.2020, 07:25)admin Wrote: Open scripting editor and get your script id (editor?id=123). Use this script to stop a running script with a certain id.
Code:
id = 123
os.execute('pkill -f "scripting-event.lua ' .. id .. ' "')
Note that this will work only for event scripts. For resident scripts use script.disable(script_name)

for an event script, dose this kill all running instances for the event script?
And is it possible to check if there are running instances before using the above?
Reply
#5
As I've said - open the editor and you will see the id in the address bar.
   
Otherwise you will need db queries.
Reply
#6
Yes, this will stop all running instances. If you want to get PIDs of a certain event script, you can use this script:
Code:
id = 123
pids = io.readproc('pgrep -f "scripting-event.lua ' .. id .. ' "')
log(pids)
Reply


Forum Jump: