LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-23-2023, 09:22 PM   #1
wh33t
Member
 
Registered: Oct 2003
Location: Canada
Posts: 924

Rep: Reputation: 61
Red face If I "queue" up a bunch of commands on the terminal, is there a way to edit/cancel them while they are running?


Like if I do the following

Code:
dd if=/dev/sda of=disk.img; poweroff
The dd command takes a while to complete, what if I decide that I don't want my machine to shut off after it's complete. Is there a way to somehow cancel that poweroff in there without prematurely terminating the dd?
 
Old 11-23-2023, 10:59 PM   #2
RandomTroll
Senior Member
 
Registered: Mar 2010
Distribution: Slackware
Posts: 1,973

Rep: Reputation: 271Reputation: 271Reputation: 271
You can make poweroff non-executable.
 
Old 11-24-2023, 12:05 AM   #3
___
Member
 
Registered: Apr 2023
Posts: 156
Blog Entries: 1

Rep: Reputation: Disabled
I tried ctrl-z with
sleep 22;echo x

It stopped the sleep without killing it, so I could fg it later, but the bad news is that it immediately executed the echo x (which would be the poweroff in your case).

I would check `which poweroff'. Then, ls -l it. In my case it's just a symlink to /bin/systemctl! So, chmod operates on systemctl! Which would work, but then you're messing with something *other than* what you thought you were (ls -lc)
So I sudo mv it to /sbin/powerof #one less f
ctrl-z gives the can't find poweroff error message. fg brings back your first command.
WHEN my long first command finished, then I mv'ed it back ok.
 
Old 11-24-2023, 01:55 AM   #4
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,832

Rep: Reputation: 1219Reputation: 1219Reputation: 1219Reputation: 1219Reputation: 1219Reputation: 1219Reputation: 1219Reputation: 1219Reputation: 1219
With newline instead of semicolon it seems to work:
Code:
sleep 20
echo x
echo y
The commands are queued up in memory.
Pause the current command with Ctrl-Z:
Code:
^Z
A "Stopped" message should occur.
Now continue the current process with the fg command:
Code:
fg
The paused process continues.
And the following commands are gone.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can not cancel or release print jobs in print queue camorri Slackware 3 05-01-2023 02:19 PM
have a bunch of letter character else when pressing Alt key + a (bunch) letter BudiKusasi Linux - Software 1 12-07-2021 04:30 AM
[SOLVED] How to cancel two cron'd rsync that are running at same time, or can they both run ok anon091 Linux - Server 3 04-23-2014 09:23 AM
Linux Device Drivers...how do they work/how do you find/edit them? Need it 4 Researc dahsar Linux - General 2 06-11-2009 10:55 AM
Is there a way to manage / edit queue in xmms? sleepyrob Linux - Software 2 08-13-2006 03:32 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:44 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration