May 1, 201016 yr I've written a script that will run an encoding job with Handbrake whenever a file is found in a certain directory. Everything works great. I also check to make sure HandbrakeCLI is not already running before queuing any new file in the directory. I would also like to prevent the encode queue if the parity check is currently running. How can I check this in a script? Many thanks I'm using unRaid 4.5
May 1, 201016 yr I've written a script that will run an encoding job with Handbrake whenever a file is found in a certain directory. Everything works great. I also check to make sure HandbrakeCLI is not already running before queuing any new file in the directory. I would also like to prevent the encode queue if the parity check is currently running. How can I check this in a script? Many thanks I'm using unRaid 4.5 you need to use the following as a guide. If parity sync is not running you get this root@Tower:/boot# /root/mdcmd status | grep Resync mdResync=0 If it is running, you get something like this: root@Tower:/boot# /root/mdcmd status | grep Resync mdResync=976762552 mdResyncPos=90240 mdResyncPrcnt=0.0 mdResyncFinish=3605.2 mdResyncSpeed=4512 You can basically just grep for "mdResync=" If it is anything other than 0, a parity check is running.
May 1, 201016 yr Author Thanks for the quick reply. Executing /root/mdcmd status | grep Resync gives me one of the two result (while parity is running) in telnet... Binary file (standard input) matches OR mdResync=1465138552 mdResyncPos=1029122472 mdResyncPrcnt=70.2 mdResyncFinish=86.7 mdResyncSpeed=83788 I'm a novice at scripting, but not a total n00b. Could you help a little more with the code? #!/bin/bash if [ $(/root/mdcmd status | grep Resync) -ne 0 ] then echo "Parity running" else echo "Not Running" fi
June 9, 201016 yr Author Just a note. If parity is not running, you need to add the -a option to grep if [ $(/root/mdcmd status | grep -a Resync= | cut -c10) == '0' ] then echo "### Parity NOT running ###" fi
June 10, 201016 yr if [ `/root/mdcmd status | grep -aw mdResync | awk -F= '{print$2}'` != 0 ]; then echo "Parity check in progress" return 1 fi Your version of just doing grep-a Resync could have problems in the event where parity check is running as grep would return multiple lines and the test statement won't handle it. the -w flag forces grep to match the word entirely. awk -F= '{print$2}' is a neater way of selecting the data after the equal sign IMO
June 10, 201016 yr if [ `/root/mdcmd status | grep -aw mdResync | awk -F= '{print$2}'` != 0 ]; then echo "Parity check in progress" return 1 fi Your version of just doing grep-a Resync could have problems in the event where parity check is running as grep would return multiple lines and the test statement won't handle it. the -w flag forces grep to match the word entirely. awk -F= '{print$2}' is a neater way of selecting the data after the equal sign IMO And yours might choke if something other than a numeric value is returned at some point in the future, or nothing is returned. Probably better to put the "0" in "quotes" as well as the entire `grep ...| awk ` command" if [ "`/root/mdcmd status | grep -aw mdResync | awk -F= '{print $ 2}'`" != "0" ]; then echo "Parity check in progress" return 1 fi
June 10, 201016 yr And yours might choke if something other than a numeric value is returned at some point in the future, or nothing is returned. Future proofing - good catch
Archived
This topic is now archived and is closed to further replies.