Ubuntu 14.04下SSH执行apt full-upgrade超时后进程挂起求助
apt full-upgrade After SSH Timeout on Ubuntu 14.04 Alright, let's break down how to get your stuck apt process back on track, plus fix the apt-get autoclean error you're seeing.
First: Understand the Process Chain
You ran pstree -psa 3409 to check the hung process—likely, the output shows apt or apt-get waiting on a child process (most often dpkg) that's stuck waiting for user input (like a config file overwrite prompt) or a lock conflict. That's the root of the hang.
Method 1: Reattach the Hung Process to Your Current Session (Recommended)
The reptyr tool lets you "steal" a running process and attach it to your current SSH terminal. Here's how to use it:
- Install reptyr first (it's available in Ubuntu 14.04 repos):
sudo apt-get install reptyr - Attach to the hung apt process (replace
3409with your actual process ID if needed):
This will pull up the interactive prompt that was causing the hang (e.g., asking if you want to keep your existing config file or replace it). Answer the prompt, and thesudo reptyr 3409full-upgradeshould resume normally.
Method 2: Resolve Dpkg Lock/Configuration Issues
If reptyr isn't working, or if the hang is due to a stuck dpkg process:
- First, kill any stray apt/dpkg processes (be careful here—only kill the ones related to your hung upgrade):
Wait a few seconds, then check if the process is gone withsudo kill -TERM 3409ps aux | grep apt. - Remove any leftover lock files (these can block apt/dpkg from running):
sudo rm /var/lib/dpkg/lock sudo rm /var/lib/apt/lists/lock sudo rm /var/cache/apt/archives/lock - Finish configuring any partially installed packages:
sudo dpkg --configure -a - Once that's done, you can restart the upgrade:
sudo apt full-upgrade
Fixing apt-get autoclean Errors
The autoclean issue is almost always tied to a corrupted cache or leftover locks. Try these steps:
- First, ensure no other apt processes are running (use
ps aux | grep aptto check). - Clear the full apt cache first:
sudo apt-get clean - Now run autoclean again:
If this still fails, check thesudo apt-get autoclean/var/cache/apt/archives/directory for damaged.debfiles—delete any that look corrupted (they might have zero size or incomplete filenames), then retry autoclean.
Prevent This From Happening Again
To avoid losing control of long-running commands like full-upgrade when SSH times out, use a terminal multiplexer like screen:
- Install screen:
sudo apt-get install screen - Start a new screen session:
screen - Run your
apt full-upgradeinside this session. Even if your SSH connection drops, the process will keep running in the background. - When you reconnect via SSH, reattach to the screen session with:
screen -r
内容的提问来源于stack exchange,提问作者OddDev

