Log inUsernamePassword
Log me on automatically each visit    
Register
Register
Log in to check your private messages
Log in to check your private messages
SMS Forum Index » SMS User Support

Post new topic   Reply to topic
Switching off the server for a night
View previous topic :: View next topic  
Author Message
miikew
Member


Joined: 28 Oct 2009
Posts: 77

PostPosted: Mon Jan 21, 2013 3:32 pm    Post subject: Switching off the server for a night Reply with quote

Hello
i want to ask about automatic switching off the pc

My server works 24/7 but i'm not using it over night, so i decided to switch it off for a night

is there any solution to do that automatically ?

i want to switch it off on 00:00 and start it up at 8:00

this server only shares some movies locally and downloading torrents so i wanted to monitor the connections, if server do nothing at 00:00 it should power off then start at 8:00, but if server is downloading smth, it should wait until the end and then switch off

i know that i want a lot but we have 21st century Smile it should be "out of the box"

thanks in advance
mw
Back to top
View user's profile Send private message
gerasimos_h
Site Admin


Joined: 09 Aug 2007
Posts: 1752
Location: Greece

PostPosted: Mon Jan 21, 2013 3:53 pm    Post subject: Reply with quote

Well, shutting down the PC is quite easy, even running a program to check connections and status.

But to automatically start the PC, it must supported by BIOS.
Look at your BIOS settings under POWER tab for something like "resume by alarm" or "wake up alarm" and see if you can program it.

gerasimos_h

_________________
Superb! Mini Server Project Manager
http://sms.it-ccs.com
Back to top
View user's profile Send private message Visit poster's website
miikew
Member


Joined: 28 Oct 2009
Posts: 77

PostPosted: Mon Jan 21, 2013 4:00 pm    Post subject: Reply with quote

i'm trying this

rtcwake -u -s 120 -m mem

but it wont wake up

hmmm
Back to top
View user's profile Send private message
gerasimos_h
Site Admin


Joined: 09 Aug 2007
Posts: 1752
Location: Greece

PostPosted: Mon Jan 21, 2013 5:32 pm    Post subject: Reply with quote

So you want to suspend...
What's your SMS version...

Try running
Code:
rtcwake -u -s 120 -m on


gerasimos_h

_________________
Superb! Mini Server Project Manager
http://sms.it-ccs.com
Back to top
View user's profile Send private message Visit poster's website
miikew
Member


Joined: 28 Oct 2009
Posts: 77

PostPosted: Tue Jan 22, 2013 9:28 am    Post subject: Reply with quote

Operating system Slackware Linux 12.2.0
Webmin version 1.480
Time on system Tue Jan 22 08:21:43 2013
Kernel and CPU Linux 2.6.29.6-smp on i686
System uptime 10 hours, 37 minutes
CPU load averages 0.00 (1 min) 0.00 (5 mins) 0.00 (15 mins)
Real memory 496.89 MB total, 74.32 MB used


i want to lower costs of energy, if i can do this by suspending, hibernating, switching off, thats fine for me, resume time is irrelevant,
the pc is not so old, i hope it has all functions in bios to allow that

btw how to power down HDDs on idle after lets say 30 minutes ?

i also found in log file

Jan 21 21:47:43 mediaserver kernel: rtc_cmos 00:03: RTC can wake from S4
Jan 21 21:47:43 mediaserver kernel: rtc_cmos 00:03: rtc core: registered rtc_cmos as rtc0
Jan 21 21:47:43 mediaserver kernel: rtc0: alarms up to one month, 114 bytes nvram, hpet irqs


is it meaning smth good for me ?
Back to top
View user's profile Send private message
gerasimos_h
Site Admin


Joined: 09 Aug 2007
Posts: 1752
Location: Greece

PostPosted: Wed Jan 23, 2013 2:14 pm    Post subject: Reply with quote

If you are going to power off PC, you need BIOS support to power on and that's at a specific time, e.g. 08:00
If your BIOS don't support it then you can only use standby...

To put disks to idle use hdparm
http://sms.it-ccs.com/forum/viewtopic.php?p=3025#3025

Try using suspend-to-disk (S4)
Code:
rtcwake -u -s 300 -m disk


gerasimos_h

_________________
Superb! Mini Server Project Manager
http://sms.it-ccs.com
Back to top
View user's profile Send private message Visit poster's website
miikew
Member


Joined: 28 Oct 2009
Posts: 77

PostPosted: Fri Feb 01, 2013 11:20 am    Post subject: Reply with quote

i checked above and smth is wrong, but also found that my pc can wake on alarm and can be defined time of it so generally i can switch it on on particular time eg. 8:00, now i need to switch it off at 00:05, can you tell me how to do it gentle, without killing for example wtorrent and if someone is downloading a movie from NFS ?
Back to top
View user's profile Send private message
gerasimos_h
Site Admin


Joined: 09 Aug 2007
Posts: 1752
Location: Greece

PostPosted: Fri Feb 01, 2013 3:18 pm    Post subject: Reply with quote

Well, the problem would be checking for NFS, although check this script

Code:
#!/bin/sh

check_current_connections() {

# samba connections by locks (Windows clients)
smbstatus -L|grep "-" -A 1 2> /dev/null
if [ "$?" = "1" ]; then
export stat1=off
else
export stat1=on
fi
# samba connections by Shares to catch all clients including unix.
if [ "$(smbstatus -S|grep "-" -A 1|tail -1)" = "" ]; then
export stat2=off
else
export stat2=on
fi
# ftp connections proftpd
if [ "$(pidof proftpd)" != "" ]; then
ftpcount |grep -oq "0 users" 2> /dev/null
if [ "$?" = "0" ]; then
export stat3=off
else
export stat3=on
fi
elif [ "$(pidof proftpd)" = "" ]; then
export stat3=off
fi
# ftp connections vsftpd
ps aux|grep vsftpd|grep -v "grep" 2> /dev/null
if [ "$?" = "1" ]; then
export stat4=off
else
export stat4=on
fi

# ssh connections including sshfs
ps aux |grep "sshd:"|grep -v "grep" 2> /dev/null
if [ "$?" = "1" ]; then
export stat5=off
else
export stat5=on
fi
# check nfs mount
netstat |grep nfs 2> /dev/null
if [ "$?" = "1" ]; then
export stat6=off
else
export stat6=on
fi
}

while [ 0 ]
do
 check_current_connections
 if [ "$stat1" = "off" -a "$stat2" = "off" -a  "$stat3" = "off" -a  "$stat4" = "off" -a  "$stat5" = "off" -a  "$stat6" = "off" ]; then
halt
 break;
 fi
done


Save it as check.sh , and add a cronjob e.g.
Code:
5 0 * * *  check.sh  #shutdown PC

or run it manually to test it.

Mind the for nfs check mounts, so you should unmount NFS from clients for this to work.

gerasimos_h

_________________
Superb! Mini Server Project Manager
http://sms.it-ccs.com
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    SMS Forum Index » SMS User Support All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

SMS - Superb! Mini Server Project © 2016
Powered by phpBB © 2001, 2002 phpBB Group
iCGstation v1.0 Template By Ray © 2003, 2004 iOptional