Page 1 of 1

dont wait for script to finish

Posted: June 28th, 2017, 7:08 am
by derdigge
Hello every one.

For my personal usecase i need to transfer the downloded data to different nas boxes here at home.
It is possible and a performancegain to do so. Sabnzbdplus allways waits for script and (child/sub)processes to finish.

Scripts are working it gets everything done as ecxpected but i need asynchronus behavior.

Code: Select all

#!/bin/bash 

max_thread=2

while [[ ($(pgrep -cf "/root/.dl/scripts/transfer.sh") -ge $max_thread) ]]; do
	sleep 1
done

nohup /root/.dl/scripts/transfer.sh $@ & exit 0
does anybody know how to achive this ?

Thanks

Re: dont wait for script to finish

Posted: June 28th, 2017, 4:27 pm
by jcfp
Haven't checked if this works, but my first thought would be to simply use the script called from sab to run another one in the background. On the command line at least, something like this would return immediately:

Code: Select all

#!/bin/sh

sleep 60 &

Re: dont wait for script to finish

Posted: June 29th, 2017, 2:00 am
by derdigge
That desent work. sab is waiting for childprocesses tu finish. but that one worked 4 me

http://software.clapper.org/daemonize/

with:

/usr/bin/daemonize my_script.sh "$@"

$@ shares all environvars with the subscript. so everything is available like discribed here:

https://sabnzbd.org/wiki/scripts/post-p ... ng-scripts

good luck