Bitcoin Forum

Bitcoin => Mining => Topic started by: mewantsbitcoins on May 05, 2011, 02:00:26 PM



Title: Turn miner on/off
Post by: mewantsbitcoins on May 05, 2011, 02:00:26 PM
I would like my miner to turn on/off at a specific time of day. What is the best way to go about it? Has anyone maybe got a script for that? Solutions for both Linux and Windows are welcome.


Title: Re: Turn miner on/off
Post by: Dayofswords on May 05, 2011, 09:00:10 PM
or if on windows, the task scheduler that no one uses these days


(i need to learn cron...)


Title: Re: Turn miner on/off
Post by: grndzero on May 05, 2011, 09:31:42 PM
Starting a process on either OS is pretty easy from either Task Scheduler or cron.

Stopping them is a little harder. I don't know about Windows, but the tools are already exist in linux to parse the process list to get the process id's of your miners and pass them along to the kill command. I know pslist from pstools will give you a list of precess id's on windows but you would have to come up with something else to parse the list and find the id's you're looking for.

I already have scripts to kill my miners and restart them from the command line and tested them with cron in linux.


Title: Re: Turn miner on/off
Post by: dust on May 05, 2011, 09:54:14 PM
On linux, use cron with

Code:
pkill -9 poclbm
for poclbm or

Code:
pkill -9 python
for pheonix


Title: Re: Turn miner on/off
Post by: grndzero on May 05, 2011, 10:10:05 PM
On linux, use cron with

Code:
pkill -9 poclbm
for poclbm or

Code:
pkill -9 python
for pheonix

on ubuntu both programs look like:

/usr/bin/python ./phoenix.py
/usr/bin/python ./poclbm.py

and they aren't the only programs that are python scripts so just killing python could kill other system programs inadvertently

if pgrep phoenix or poclbm returns the right pids then pkill should work for both


Title: Re: Turn miner on/off
Post by: dust on May 05, 2011, 10:25:36 PM
Grndzero, you are correct that pkill could interfere with other processes.  My mining systems are dedicated and there are no other processes named "python".


Title: Re: Turn miner on/off
Post by: grndzero on May 05, 2011, 10:33:02 PM
Grndzero, you are correct that pkill could interfere with other processes.  My mining systems are dedicated and there are no other processes named "python".

Mine is also, but when I originally wrote my kill scripts (not knowing about pkill and pgrep) and seeing that the primary process was python, not the script I found 1 or 2 other processes (I think they are services) on ubuntu that python is the primary process for.


Title: Re: Turn miner on/off
Post by: Vwlopez3 on May 05, 2011, 10:47:58 PM
Yes i would also be interested in this perhaps a windows option?


Title: Re: Turn miner on/off
Post by: grndzero on May 05, 2011, 10:52:45 PM
Yes i would also be interested in this perhaps a windows option?

Looks like you can kill processes by name from the command prompt (or batch file) with taskkill

http://www.addictivetips.com/windows-tips/kill-processes-from-the-command-prompt-in-windows-7/


Title: Re: Turn miner on/off
Post by: [Tycho] on May 05, 2011, 11:32:56 PM
Starting a process on either OS is pretty easy from either Task Scheduler or cron.
Stopping them is a little harder.
I'm not sure about windows 7, but in previous versions you can set maximum running time for a sheduled task, after which it will be killed automatically.


Title: Re: Turn miner on/off
Post by: grndzero on May 05, 2011, 11:39:15 PM
Starting a process on either OS is pretty easy from either Task Scheduler or cron.
Stopping them is a little harder.
I'm not sure about windows 7, but in previous versions you can set maximum running time for a sheduled task, after which it will be killed automatically.

Create Task, Settings

Stop If Task Runs Longer Than:
1,2,4,8,12 hours or 1,3 days ... can't manually input values

suck


Title: Re: Turn miner on/off
Post by: mintymark on May 05, 2011, 11:40:27 PM
I use a script that does the stopping and starting. I posted a slightly earlier version of it here

http://bitcointalk.org/index.php?topic=6307.msg94337#msg94337

It also has the feature that you can make the mier work only when not using the computer if you want.

If you want to make it work only at certain times, use this script and cron.

All of this is linux only, I'm afraid.



Title: Re: Turn miner on/off
Post by: marcus_of_augustus on May 05, 2011, 11:50:13 PM
On linux, use cron with

Code:
pkill -9 poclbm
for poclbm or

Code:
pkill -9 python
for pheonix

on ubuntu both programs look like:

/usr/bin/python ./phoenix.py
/usr/bin/python ./poclbm.py

and they aren't the only programs that are python scripts so just killing python could kill other system programs inadvertently

if pgrep phoenix or poclbm returns the right pids then pkill should work for both

Both phoenix and poclbm can be started by using the explicit python call (from inside the relevant directory or using the absolute path)

eg.

$python phoenix -u .....

or

$python poclbm -u ....

so on a dedicated mining rig without other python called processes running "$pkill -9 python" would work fine from cron. I've always wondered what the difference is between using the python prefix command or just the $./process.py ... doesn't seem to make a difference to hashrate but who knows ...


Title: Re: Turn miner on/off
Post by: mintymark on May 06, 2011, 08:00:14 AM
Moa,

Its not a good idea to use the -9 argument here. This shuts down the processes without allowing them to do shutdown gracefully. just use kill <processid> or pkill <processname> and this will give the process a chance to shutdown correctly.


Title: Re: Turn miner on/off
Post by: marcus_of_augustus on May 06, 2011, 11:20:39 AM
Moa,

Its not a good idea to use the -9 argument here. This shuts down the processes without allowing them to do shutdown gracefully. just use kill <processid> or pkill <processname> and this will give the process a chance to shutdown correctly.

Yeah, you are right ... i've got into bad habit of always kill -9 since I mostly use it on hung/runaway processes ... for a scheduled cron shutdown drop the -9 ... just kill or pkill should be good.


Title: Re: Turn miner on/off
Post by: mewantsbitcoins on May 06, 2011, 07:57:32 PM
Hi all. Thanks for your replies. I am running jgarzik's miner on CentOS and here's how I did it:

Code:
crontab -e

Code:
00 21 * * * /[path to your miner]/minerd -t 2 -a cryptopp_asm32 --url [url of your pool] --userpass [username]:[password] &
00 09 * * * pkill minerd

This starts miner everyday at 21:00 and stops it at 09:00


Title: Re: Turn miner on/off
Post by: Grinder on May 06, 2011, 09:06:50 PM
so on a dedicated mining rig without other python called processes running "$pkill -9 python" would work fine from cron. I've always wondered what the difference is between using the python prefix command or just the $./process.py ... doesn't seem to make a difference to hashrate but who knows ...
The only difference is that if you do python <file> the shell will execute python which then loads and runs <file>. If you run ./<file> the shell will read <file>, see the starting #! characters (pronounced shebang) and then execute the program in the first line of it (often /usr/bin/python) with <file> as parameter.