🅭

How to schedule Folding@home to only run during winter nights

Folding@home is a distributed computing platform that lets you donate your spare unused processor power (and electricity) to contribute to medical research. The project was initially set up to do protein folding for cancer research. The project has since expanded to help scientists understand and fight all sorts of diseases including SARS-CoV-2 (the virus that causes COVID-19.)

All you need to get going is to download and set up the Folding@home client (FAHClient). It’s available on Linux, macOS, and Windows. The FAHClient can be set up to run only when your computer is idle and it’s not running off battery power. Unfortunately, FAHClient doesn’t come with any built-in scheduling tools to control which hours of the day it can run.

FAHClient will cause your computer to output more heat and noise as it churns through its allotted research-workloads. You may be fine with this depending on where and how you live. Like most Europeans, I live in an apartment that doesn’t have an air-condition, and it can get very hot during the summer months.

I’m happy to help with medical research, but I don’t want my computer to warm up the apartment in summer. I also don’t want it to output any more fan noise than absolutely necessary during the day. Electricity is also cheaper during off-peak hours — like in the middle of the night — and it gets cold during those hours in winter. I decided that I only wanted to let FAHClient run in the night and during the colder months of the year. That way, my computer can still contribute to scientific research; but only when the noise won’t bother me, electricity is cheaper, and the heat can help keep the apartment warm.

Luckily, all the leading operating systems have built-in tools to schedule when to run programs. This tutorial will show you how to pause and resume FAHClient on a schedule using the tools provided in your operating system of choice. Let’s get started.

Prerequisites

Complete the following steps and then move on to the configuration steps specific for your operating system below.

  1. Install and set up the Folding@home client (FAHClient). The tutorial assumes that you’ve installed the client to the default location.
  2. Configure your computer’s power-saving settings to allow the computer to remain powered-on at night. Review the settings in System Settings/Preferences: Energy Savings.
  3. Configure FAHClient to pause on start-up. Here’s how:
    1. Open FAHControl. It’s a program installed alongside FAHClient. You can find it by searching in the Start menu on Windows or using Spotlight search on macOS.
    2. Click Configure and select the Expert pane.
    3. Click Add underneath the Extra client options panel.
    4. Type pause-on-start as the option name and true as its value. Click OK.

What follows are instructions for how to pause and resume FAHClient on a schedule on Windows 10 [skip to Windows instructions], macOS [skip to macOS instructions], and Linux (systemd) [skip to Linux instructions].

These instructions will start FAHClient at 01:15 at night and stop it at 06:00 from October through March. Maybe you only want to run it at day when your solar panels are generating electricity? You can follow the optional instruction step to choose a different schedule.

Windows 10

Most users aren’t familiar with task scheduling in Windows. It may seem overwhelming, but I’ll try to break down each step and walk you through the process.

  1. Download fahclient-unpause.xml and fahclient-pause.xml.
  2. [Optional] Right-click on the downloaded files and choose Edit. Modify the hour and minutes in the StartBoundary to set your own scheduled times (the date just needs to be any date in the past). Modify the months listed in ScheduleByMonth. Take care not to make any other changes to the file.
  3. Open the Task Scheduler program (use the search field in the Start Menu to find it.)
  4. Expand the Action menu in the menu bar and select Import task.
  5. Select the downloaded file and click OK.

You’re all set up! You can change the scheduled time or remove the task from inside the Task Scheduler. The tasks are called fahclient-unpause and fahclient-pause. You can also modify the schedule from inside the Task Manager. However, the graphical tool is unintuitive and difficult to use. You may want to bookmark this article for future reference.

macOS

The launchd system handles scheduled tasks on macOS, but it doesn’t have a graphical user interface like Task Scheduler on Windows. The setup process may seem overwhelming, but I’ll try to break down each step and walk you through the process.

  1. Download local.fahclient.unpause.plist and local.fahclient.pause.plist.
  2. [Optional] Right-click on the downloaded files and choose Open With: Other: TextEdit. Modify the month, hour, and minutes fields to set your own schedule. Study the structure of the file and take care only to modify the numeric time values.
  3. Open Finder. Expand the Go menu in the top bar and select Library. If you don’t see Library in the menu, select Go To Folder, and type ~/Library and press Enter.
  4. Open the LaunchAgents folder inside your Library folder (or create it if it doesn’t exist).
  5. Move the downloaded files into this folder. You can use drag-and-drop from the Downloads folder or copy-and-paste.
  6. Log out and back in again (or restart your Mac) from the Apple menu in the top left corner.

That’s it. You’re all set. You can remove or modify the scheduled time in the files later to undo or change the behavior. You may want to bookmark this article for future reference.

Linux (systemd)

  1. Download fahclient-unpause.service, fahclient-unpause.timer, fahclient-pause.service, and fahclient-pause.timer.
  2. [Optional] Edit the downloaded timer files and modify it to set your own log-out time. Take care not to make any other changes to the file.
  3. Move the downloaded files into the ~/.config/systemd/user/ directory inside your Home folder (or create the folder if it doesn’t exist).
  4. Open a terminal shell and type the following three commands:
systemd --user daemon-reload

systemd --user enable --now \
        fahclient-unpause.timer

systemd --user enable --now \
        fahclient-pause.timer

You’re all set up! You can change the scheduled time by modifying the timer files or remove it by deleting the timer and service files. You can review the service files if you’re curious about how this works under the hood.

Finish up before pausing

These instructions have used the pause action; causing FAHClient to pause at the scheduled time. You can make your computer submit completed workloads earlier by giving it time to finish ongoing work. Instead of pausing on schedule, FAHClient will work until the scheduled time and then continue, but pause once it has completed the current workload. This can take any time from minutes to hours.

You can switch to finishing workloads before pausing by editing the task file and locating “--send-pause” inside it. Replace that command with “--send-finish”.

Haven’t you joined a folding team yet? You’re welcome to join the Ctrl blog folding team! (#252041)