How do I run XMRig at login on macOS with launchd?
You can run XMRig when you log in to macOS by creating a LaunchAgent, a small settings file that tells macOS’s built-in service manager, launchd, what to start. This runs XMRig under your user account, without sudo, and starts mining after you log in—not before.
Prepare XMRig and its configuration
Only do this on a Mac you own or have explicit permission to use. Automatic mining uses electricity and can increase heat, fan noise, and battery drain.
Put your trusted XMRig executable and working config.json in a permanent folder. The example below uses:
/Users/YOURNAME/Mining/xmrig/xmrig
/Users/YOURNAME/Mining/xmrig/config.json
Replace YOURNAME everywhere below with your macOS account’s short name. Run whoami in Terminal if you are unsure.
Test XMRig manually first:
"/Users/YOURNAME/Mining/xmrig/xmrig" \
--config="/Users/YOURNAME/Mining/xmrig/config.json"
Confirm that it connects to your chosen pool and uses your correct wallet address. Then press Control-C to stop it.
In config.json, make sure "background" is false. XMRig must stay in the foreground so launchd can manage it.
Create your login agent
Create the folders for your agent and logs:
mkdir -p "$HOME/Library/LaunchAgents" \
"$HOME/Library/Logs/XMRig"
Save the following as plain text at:
~/Library/LaunchAgents/com.local.xmrig.plist
A .plist is Apple’s settings-file format. This one uses XML, a structured text format:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.local.xmrig</string>
<key>ProgramArguments</key>
<array>
<string>/Users/YOURNAME/Mining/xmrig/xmrig</string>
<string>--config=/Users/YOURNAME/Mining/xmrig/config.json</string>
<string>--no-color</string>
</array>
<key>WorkingDirectory</key>
<string>/Users/YOURNAME/Mining/xmrig</string>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>ThrottleInterval</key>
<integer>30</integer>
<key>StandardOutPath</key>
<string>/Users/YOURNAME/Library/Logs/XMRig/output.log</string>
<key>StandardErrorPath</key>
<string>/Users/YOURNAME/Library/Logs/XMRig/error.log</string>
</dict>
</plist>
Use absolute paths inside the file: launchd does not expand ~ or $HOME there. Each command argument needs its own <string> entry.
RunAtLoad starts XMRig when the agent loads. KeepAlive restarts it if it exits; the throttle limits rapid restart attempts.
Load it and check that it works
Validate the file, then load it into your logged-in session:
plutil -lint "$HOME/Library/LaunchAgents/com.local.xmrig.plist"
launchctl bootstrap "gui/$(id -u)" \
"$HOME/Library/LaunchAgents/com.local.xmrig.plist"
Here, $(id -u) supplies your numeric user ID. Run these commands as yourself, without sudo.
Check the service and its output:
launchctl print "gui/$(id -u)/com.local.xmrig"
tail -n 50 "$HOME/Library/Logs/XMRig/output.log" \
"$HOME/Library/Logs/XMRig/error.log"
If startup fails, check paths, executable permissions, and configuration errors. macOS security checks may also block an untrusted download; verify its source rather than disabling system protections. Log files can grow, so check their size periodically.
Stop, change, or remove it
Because KeepAlive restarts XMRig, unload the agent to stop mining reliably:
launchctl bootout "gui/$(id -u)" \
"$HOME/Library/LaunchAgents/com.local.xmrig.plist"
After editing the agent, load it again with bootstrap. To remove automatic startup permanently, unload it and delete its .plist file.
The bottom line
A user LaunchAgent starts XMRig at login without administrator privileges. It does not keep your Mac mining through sleep or logout, and automatic startup does not guarantee profitable mining.
