40
submitted 2 days ago* (last edited 2 days ago) by sem@piefed.blahaj.zone to c/linux@programming.dev

I don't want the system to shutdown in the middle of the upgrade, but I've already started the upgrade in the GUI.

Is there a better way, maybe involving the apt lock?

EDIT: Thank you for all the helpful suggestions. Hopefully this helps the next person. My upgrade actually finished on its own while I was posting. ๐Ÿ˜‚

you are viewing a single comment's thread
view the rest of the comments
[-] fruitcantfly@programming.dev 14 points 2 days ago

If you can run sudo without a password, you could do something like:

There's no need for password-less sudo. Instead, you can use bash -c to run a set of commands via sudo:

sudo bash -c "while true;do apt update && shutdown -h 5; sleep 5m;done"
[-] dohpaz42@lemmy.world 11 points 2 days ago

Why do you need the while true?

[-] forestbeasts@pawb.social 6 points 2 days ago

Otherwise it'd only check for the lock once. It'd run, go "oops, apt is in use!", and quit, and never check again.

The loop here is what makes it check again at all.

-- Frost

[-] TwilightKiddy@programming.dev 4 points 2 days ago

I suppose it would be useful for flakey internet connection, then your update would restart 5 minutes after losing the connection. It surely has a yucky aftertaste, though.

[-] fruitcantfly@programming.dev 4 points 2 days ago

No, the idea was that apt update would keep failing while the system upgrade was running (and holding the lock):

$ apt update
E: Could not get lock /var/lib/apt/lists/lock. It is held by process 1704856 (apt)
N: Be aware that removing the lock file is not a solution and may break your system.
E: Unable to lock directory /var/lib/apt/lists/

But there are better ways of waiting for a process to finish, that other people have shared

[-] azimir@lemmy.ml 2 points 2 days ago

Nice. Sudo once, then run the shell until done. Much more elegant.

this post was submitted on 04 Jul 2026
40 points (100.0% liked)

Linux

14208 readers
246 users here now

A community for everything relating to the GNU/Linux operating system (except the memes!)

Also, check out:

Original icon base courtesy of lewing@isc.tamu.edu and The GIMP

founded 3 years ago
MODERATORS