You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Ctrl+Shift+L锁屏后终端任务暂停,如何让任务后台持续运行?

Why Your Terminal Tasks Pause When Locking the Screen & How to Fix It

Hey there! This isn’t a mistake on your end—this issue usually boils down to system settings or how your terminal session is tied to your graphical desktop. Let’s break down the most common reasons and how to get those compile tasks running nonstop in the background:

1. Check Desktop Environment Power Saving Settings

Most desktop environments (like GNOME, KDE, Xfce) include power-saving features that throttle or pause non-essential processes when the screen locks to conserve energy. Here’s how to tweak this:

  • GNOME: Open Settings > Power. Disable any "Suspend when inactive" options, and switch the power profile from "Power Saver" to "Balanced" or "Performance".
  • KDE: Go to System Settings > Power Management > Energy Saving. Turn off settings that pause applications or trigger system suspend when the screen is locked.
  • Xfce: Navigate to Settings > Power Manager > System. Ensure "Suspend when inactive" is set to "Never".

2. Run Tasks in a Detached Terminal Session

If your terminal is linked directly to your graphical session, locking the screen might freeze that entire session. The solution here is to use a tool that keeps your tasks running independently:

  • Using screen:
    1. Launch a new screen session with screen
    2. Start your compile command (e.g., make install or npm run build)
    3. Detach from the session by pressing Ctrl+A followed by D
    4. Lock your screen—your task will keep chugging along. To reattach later, run screen -r
  • Using tmux (a more modern, feature-rich alternative):
    1. Start a tmux session with tmux
    2. Run your task
    3. Detach with Ctrl+B then D
    4. Reconnect later with tmux attach

3. Disable Terminal Inactivity Pausing

Some terminal emulators have a setting that pauses processes when the window isn’t focused or the screen is locked. Check your terminal’s preferences:

  • Open your terminal’s settings (usually via the menu bar or right-click)
  • Look for options like "Pause processes when terminal is inactive" or "Freeze when not focused"
  • Uncheck this setting if it’s enabled

4. Adjust Systemd Login Session Behavior

If you’re using systemd, your login session might be marked as "inactive" when the screen locks, leading to process throttling. Here’s how to fix it:

  1. Check if your session goes inactive on lock with:
    loginctl show-session $XDG_SESSION_ID -p Active
    
    If it returns Active=no when locked, proceed to the next step.
  2. Edit the systemd logind config file with sudo nano /etc/systemd/logind.conf
  3. Find the lines for IdleAction and IdleActionSec, set them to:
    IdleAction=ignore
    IdleActionSec=0
    
  4. Save the file and restart the logind service with sudo systemctl restart systemd-logind (note: this might log you out, so save your work first!)

内容的提问来源于stack exchange,提问作者gerdb

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 09:28:43