dont wait for script to finish

Come up with a useful post-processing script? Share it here!
Post Reply
derdigge
Newbie
Newbie
Posts: 7
Joined: May 28th, 2012, 10:24 am

dont wait for script to finish

Post 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
User avatar
jcfp
Release Testers
Release Testers
Posts: 1004
Joined: February 7th, 2008, 12:45 pm

Re: dont wait for script to finish

Post 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 &
derdigge
Newbie
Newbie
Posts: 7
Joined: May 28th, 2012, 10:24 am

Re: dont wait for script to finish

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