Shutdown host system ?
Shutdown host system ?
Hi guys,
I have been using sabnzbd for few months now
It is 10+ program just great - thanks to all of you who helped develop it.
I have one question - i know it is a long shot but I have to ask.
Tried googling and serching forum with no luck - maybe it is my
limited knowledge of how things work -soi don't enter right words in search,
or my limited knowledge of english
I am using sabnzbd on openelec system, it is my primary downloader,
I would like to schedule my system to wake every night - at lets say 2am - thsi is no problem.
But I would like my system to go to suspend if there is nothing downloading in sabnzbd,
can this be dun somehow?
If there are no files in queue - put host system to sleep.
Thank you
I have been using sabnzbd for few months now
It is 10+ program just great - thanks to all of you who helped develop it.
I have one question - i know it is a long shot but I have to ask.
Tried googling and serching forum with no luck - maybe it is my
limited knowledge of how things work -soi don't enter right words in search,
or my limited knowledge of english
I am using sabnzbd on openelec system, it is my primary downloader,
I would like to schedule my system to wake every night - at lets say 2am - thsi is no problem.
But I would like my system to go to suspend if there is nothing downloading in sabnzbd,
can this be dun somehow?
If there are no files in queue - put host system to sleep.
Thank you
Re: Shutdown host system ?
Via the API you can check if there is anything in the queue. So an approach could be:
"each 10 minutes, check if there is anything in the queue. If not, shutdown -h now"
Something in the queue:
Empty queue:
HTH
"each 10 minutes, check if there is anything in the queue. If not, shutdown -h now"
Something in the queue:
Code: Select all
sander@R540:~$ wget 'http://localhost:8080/api?mode=qstatus&output=xml&apikey=2e2983d77bae20fd998axx' -O- -o/dev/null | grep -i downloading
<state>DOWNLOADING</state>
sander@R540:~$ wget 'http://localhost:8080/api?mode=qstatus&output=xml&apikey=2e2983d77bae20fd998ad7544xxx' -O- -o/dev/null | grep -i mbleft
<mbleft>849.887286186</mbleft>
<mbleft>849.887286186</mbleft>
sander@R540:~$
Code: Select all
sander@R540:~$
sander@R540:~$
sander@R540:~$ wget 'http://localhost:8080/api?mode=qstatus&output=xml&apikey=2e2983d77bae20fd998ad7544fx' -O- -o/dev/null | grep -i downloading
sander@R540:~$
sander@R540:~$ wget 'http://localhost:8080/api?mode=qstatus&output=xml&apikey=2e2983d77bae20fd998ad754xxx' -O- -o/dev/null | grep -i mbleft
<mbleft>0.0</mbleft>
Re: Shutdown host system ?
sander thank you,
I am not a coder I just know basics of poweshell
I know this is just to much to ask but could you explain to me what to do whit this code.
Thank you
I am not a coder I just know basics of poweshell
I know this is just to much to ask but could you explain to me what to do whit this code.
Thank you
Re: Shutdown host system ?
Well, it would involve cron/crontab, shell or python scripting, SAB-api-key, and a shutdown command (possibly with root-rights).Sinisa wrote:sander thank you,
I am not a coder I just know basics of poweshell
I know this is just to much to ask but could you explain to me what to do whit this code.
Thank you
Which of these techniques do you know?
A few questions from my side:
- how do you wake up your system at night?
- how do you feed it with things to downloads?
Re: Shutdown host system ?
Thank you once again,
I thought that there might be some plugin or some other finished soulution.
As I said I am no coder - jut know Powershell basics, batch scripting basics, and OE is my first linux system,
I just know basic commands that I needed to access OE machine via SSH.
It would not be fair to ask of anyone to code scripts for me, so I will have to
put this aside.
As for your questions,
I use resume by RTC alarm in BIOS to wake up my system.
I feed SAB with couchpotato and sickberad, which are active all the time
Thank you for your time and will to help me
Really appreciate that
I thought that there might be some plugin or some other finished soulution.
As I said I am no coder - jut know Powershell basics, batch scripting basics, and OE is my first linux system,
I just know basic commands that I needed to access OE machine via SSH.
It would not be fair to ask of anyone to code scripts for me, so I will have to
put this aside.
As for your questions,
I use resume by RTC alarm in BIOS to wake up my system.
I feed SAB with couchpotato and sickberad, which are active all the time
Thank you for your time and will to help me
Really appreciate that
Re: Shutdown host system ?
I was thinking - i learned powershell - i could learn shell as well as far as I see it is rather similar to C
basically - i need scrpit that will start with system - guess i cold run it from autostart.sh,
I need api to be able to conect to sab and loop if something in queue continue if queue is empty issue shutdown command
It does not seem as to complected to do
Any pointers I shoud be aver of
Thank you
basically - i need scrpit that will start with system - guess i cold run it from autostart.sh,
I need api to be able to conect to sab and loop if something in queue continue if queue is empty issue shutdown command
It does not seem as to complected to do
Any pointers I shoud be aver of
Thank you
Re: Shutdown host system ?
I had given these pointers:
"each 10 minutes, check if there is anything in the queue. If not, shutdown -h now"
"cron/crontab, shell or python scripting, SAB-api-key, and a shutdown command (possibly with root-rights)"
It's probably only a few lines of python code, one line in your crontab, and some tweaking to get it right on your system. I could write it for you, but I see little reward in this forum for doing things like that.
"each 10 minutes, check if there is anything in the queue. If not, shutdown -h now"
"cron/crontab, shell or python scripting, SAB-api-key, and a shutdown command (possibly with root-rights)"
It's probably only a few lines of python code, one line in your crontab, and some tweaking to get it right on your system. I could write it for you, but I see little reward in this forum for doing things like that.
Re: Shutdown host system ?
sander,
Thank you
I like learning stuff - I learned powershell from books and google - now i have scripts to shutdown and backup my virtual servers
I am not shore when I will have time to tackle wit this but will give it a try - just like you said i think it should be couple of lines, my biggest problem is that
i have no clue when it comes to linux.
Thank you
Thank you
I like learning stuff - I learned powershell from books and google - now i have scripts to shutdown and backup my virtual servers
I am not shore when I will have time to tackle wit this but will give it a try - just like you said i think it should be couple of lines, my biggest problem is that
i have no clue when it comes to linux.
Thank you
Re: Shutdown host system ?
First things first:
Learn cron / crontab:
sudo crontab -e
then add this line:
0 1 * * * shutdown -h now
Then save & exit, and check with:
sudo crontab -l
Post the output here.
If you did all well, the above cron entry means:
at minute =0 and hour =1, on any day, so ... each day at 01:00, shutdown the system. To test that, leave your computer on, and check that it goes to shuts down at 01:00
Learn cron / crontab:
sudo crontab -e
then add this line:
0 1 * * * shutdown -h now
Then save & exit, and check with:
sudo crontab -l
Post the output here.
If you did all well, the above cron entry means:
at minute =0 and hour =1, on any day, so ... each day at 01:00, shutdown the system. To test that, leave your computer on, and check that it goes to shuts down at 01:00
Re: Shutdown host system ?
... everything OK?
Re: Shutdown host system ?
Sinisa, this is it? It now works for you? Or did you decide to leave it without any response?
Re: Shutdown host system ?
sander,
pls except my deepest apologies.
I had some family problems to take care of, and work has been just overwhelming so I had no time for anything
Thank you for your replay and guides.
I will give it a try as soon as I catch some spare time.
Thank you and sorry once more
pls except my deepest apologies.
I had some family problems to take care of, and work has been just overwhelming so I had no time for anything
Thank you for your replay and guides.
I will give it a try as soon as I catch some spare time.
Thank you and sorry once more
Re: Shutdown host system ?
Hi sander,
sorry it took me so long, thing just got so complicated in RF I had to put learning new stuff and my xbmc project a side.
I took bobbintb's script http://forums.sabnzbd.org/viewtopic.php?t=11529t and edited it to suite my needs.
It still need a bit of work but it is working. It is set tu suspend system when teher is nothing in the queue and sab is completely idle.
I have 0,74 so I can take advantage of new api output.
When I run it manualy script suspends my system, but when I execute it with cron it does not.
Everywhere I look it is said that I should just edit crontab as root and then script will be executed as if ran by root user.
This is what I tried:
I edited crontab for root so it looks like this
now if I look at crontab log and my script log script is up and running. But for some reason it does not put my system to sleep.
Command I use to run manually
Thanks for your help.
sorry it took me so long, thing just got so complicated in RF I had to put learning new stuff and my xbmc project a side.
I took bobbintb's script http://forums.sabnzbd.org/viewtopic.php?t=11529t and edited it to suite my needs.
It still need a bit of work but it is working. It is set tu suspend system when teher is nothing in the queue and sab is completely idle.
I have 0,74 so I can take advantage of new api output.
When I run it manualy script suspends my system, but when I execute it with cron it does not.
Everywhere I look it is said that I should just edit crontab as root and then script will be executed as if ran by root user.
This is what I tried:
Code: Select all
sudo env EDITOR=nano crontab -e
Code: Select all
50 13 * * * /usr/bin/python /home/sinisa/shut.py
Command I use to run manually
Code: Select all
sudo python /home/sinisa/shut.py
Re: Shutdown host system ?
What is the output of:
sudo crontab -l
sudo crontab -l
Re: Shutdown host system ?
thanks for not giving up on me
I managed to remove need to enter password for suspend command but it did not help.
Is there a way for me to enter my user name and pass into the script it self?
Code: Select all
# m h dom mon dow command
08 19 * * * /usr/bin/python /home/sinisa/shut.py
Is there a way for me to enter my user name and pass into the script it self?
Last edited by Sinisa on October 22nd, 2012, 12:19 pm, edited 1 time in total.