Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
03-23-2017, 01:14 PM
|
#1
|
|
LQ Newbie
Registered: Dec 2011
Distribution: debian, mint, opensuse, fedora, ubuntu, fbsd
Posts: 11
Rep: 
|
Is there a cli method of running a command twice without having to type it twice?
I'm doing some backups with rsync over wifi and I am dealing with broken pipes by running my command multiple times, but typing out the command twice separated by a ; or && is tedious without being able to copy & paste the command. Is there a trick to tell my shell to run the command n times instead of writing out
Code:
rsync arguments source destination ; rsync arguments source destination
?
eta: I also just realized this would prompt me for a password each time rsync is run, any way around that?
Last edited by powderburns; 03-23-2017 at 01:20 PM.
Reason: appended
|
|
|
|
03-23-2017, 01:21 PM
|
#2
|
|
LQ Guru
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,756
|
Depends on the shell. In many you can just press the up arrow. Also in many you can press !! and it will repeat the last one again.
If you are searching through your command history, ctrl-R will search backwards for you.
|
|
|
1 members found this post helpful.
|
03-23-2017, 01:34 PM
|
#3
|
|
LQ Guru
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,756
|
Or you can run rsync in a loop until it succeeds.
Code:
while ! rsync -options source/ destination/; do true; done;
That way it will keep trying until the transfer is completed successfully.
|
|
|
2 members found this post helpful.
|
03-24-2017, 09:02 AM
|
#4
|
|
LQ Newbie
Registered: Dec 2011
Distribution: debian, mint, opensuse, fedora, ubuntu, fbsd
Posts: 11
Original Poster
Rep: 
|
Both suggestions worked great. I finished my remaining transfers without having to supervise the shell all night. Thanks for your help!
|
|
|
|
03-24-2017, 09:55 AM
|
#5
|
|
LQ Guru
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,756
|
No worries. It's a trick that also works with ssh if you use that as well. It needs tmux or screen over on the server and key-based authentication is prerequisite.
Code:
ssh-add ~/.ssh/server_key_ed25519
while ! ssh -t -i ~/.ssh/server_key_ed25519 server.example.com 'tmux a || tmux'; do sleep 1; done;
Useful when traveling or in other situations where connectivity is irregular.
|
|
|
|
All times are GMT -5. The time now is 05:54 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|