Page 1 of 1

How to run FAH on a schedule?

Posted: Sat Nov 28, 2020 11:45 pm
by StanGreen
I would like to run FAH on a schedule, so I don't have to manually start and stop it. (The "Only when idle" does not work on my PC.") I can use Windows Scheduler to start and stop the client with these commands:

Rem Start F@H
FAHClient.exe --send-pause
If %errrorlevel% == 1 (
cd C:\Users\%username%\AppData\Roaming\FAHClient
"C:\Program Files\FAHClient\HideConsole.exe" "C:\Program Files\FAHClient\FAHClient.exe"
FAHClient --send-unpause
)

Rem Kill the F@H process:
FAHClient --send-pause
Rem Use Taskkill to free memory.
taskkill /IM "FAHClient.exe" /F

Is there a better way, on Windows, to start/stop the client?

Re: How to run FAH on a schedule?

Posted: Sun Dec 06, 2020 3:13 am
by StanGreen
Since no one seems to want to comment on this, I have taken this approach. I needed to tweak the scrips for syntax. The end result is:

StartFoldingAtHome.cmd
@echo off
Rem Start Folding@Home
FAHClient.exe --send-pause
If %ERRORLEVEL% == 1 (
echo Starting Folding@Home
pushd .
cd C:\Users\%username%\AppData\Roaming\FAHClient
"C:\Program Files\FAHClient\HideConsole.exe" "C:\Program Files\FAHClient\FAHClient.exe"
popd
) else (
echo Folding@Home already started.
)
FAHClient --send-unpause

StopFoldingAtHome.cmd
@Echo Off
Rem Stop Folding@Home
echo Stopping the client.
FAHClient --send-pause
Rem Use Taskkill to free memory.
echo killing the client process
taskkill /IM "FAHClient.exe" /F

Task Scheduler:
Start Folding@Home.xml
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<Date>2020-12-05T21:50:17.1334112</Date>
<Author>DTWIN10\Stan</Author>
<URI>\Start Folding@Home</URI>
</RegistrationInfo>
<Triggers>
<CalendarTrigger>
<StartBoundary>2020-12-05T23:30:00</StartBoundary>
<Enabled>true</Enabled>
<ScheduleByDay>
<DaysInterval>1</DaysInterval>
</ScheduleByDay>
</CalendarTrigger>
</Triggers>
<Principals>
<Principal id="Author">
<UserId></UserId>
<LogonType>InteractiveToken</LogonType>
<RunLevel>LeastPrivilege</RunLevel>
</Principal>
</Principals>
<Settings>
<MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
<DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>
<StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>
<AllowHardTerminate>false</AllowHardTerminate>
<StartWhenAvailable>false</StartWhenAvailable>
<RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
<IdleSettings>
<StopOnIdleEnd>true</StopOnIdleEnd>
<RestartOnIdle>false</RestartOnIdle>
</IdleSettings>
<AllowStartOnDemand>true</AllowStartOnDemand>
<Enabled>true</Enabled>
<Hidden>false</Hidden>
<RunOnlyIfIdle>false</RunOnlyIfIdle>
<WakeToRun>false</WakeToRun>
<ExecutionTimeLimit>PT0S</ExecutionTimeLimit>
<Priority>7</Priority>
</Settings>
<Actions Context="Author">
<Exec>
<Command>cmd</Command>
<Arguments>/c start "" /min "C:\Users\Stan\Scripts\StartFoldingAtHome.cmd" ^& exit</Arguments>
</Exec>
</Actions>
</Task>

Stop Folding@Home.xml
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<Date>2020-12-05T21:50:17.1334112</Date>
<Author>DTWIN10\Stan</Author>
<URI>\Start Folding@Home</URI>
</RegistrationInfo>
<Triggers>
<CalendarTrigger>
<StartBoundary>2020-12-05T23:30:00</StartBoundary>
<Enabled>true</Enabled>
<ScheduleByDay>
<DaysInterval>1</DaysInterval>
</ScheduleByDay>
</CalendarTrigger>
</Triggers>
<Principals>
<Principal id="Author">
<UserId></UserId>
<LogonType>InteractiveToken</LogonType>
<RunLevel>LeastPrivilege</RunLevel>
</Principal>
</Principals>
<Settings>
<MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
<DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>
<StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>
<AllowHardTerminate>false</AllowHardTerminate>
<StartWhenAvailable>false</StartWhenAvailable>
<RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
<IdleSettings>
<StopOnIdleEnd>true</StopOnIdleEnd>
<RestartOnIdle>false</RestartOnIdle>
</IdleSettings>
<AllowStartOnDemand>true</AllowStartOnDemand>
<Enabled>true</Enabled>
<Hidden>false</Hidden>
<RunOnlyIfIdle>false</RunOnlyIfIdle>
<WakeToRun>false</WakeToRun>
<ExecutionTimeLimit>PT0S</ExecutionTimeLimit>
<Priority>7</Priority>
</Settings>
<Actions Context="Author">
<Exec>
<Command>cmd</Command>
<Arguments>/c start "" /min "C:\Users\Stan\Scripts\StartFoldingAtHome.cmd" ^& exit</Arguments>
</Exec>
</Actions>
</Task>

Re: How to run FAH on a schedule?

Posted: Sun Dec 06, 2020 5:01 am
by bruce
Comments:
1) Unless you're really short of VRAM, I would leave FAHClient running. It really doesn't do anything if FAH is paused. It'll probably be mostly paged out to disk anyway

2) You may want to manage slots separately. That adds a lot of complexity, though so you may not consider it worth the effort. Personally, I'd probably pause the GPU slot(s) and leave the CPU slot(s) running, but that fits my hardware and it may not apply to yours.

3) If you really want to make it complex, you might decide to test the time remaining on an active WU and do a FINISH of something that's almost done -- but that's dependent on both 1 and 2 above.

It's good to see that somebody finally posted a workable solution. Thanks.