LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How do I do other tasks in the background, and transfer files with a progress bar? (https://www.linuxquestions.org/questions/linux-newbie-8/how-do-i-do-other-tasks-in-the-background-and-transfer-files-with-a-progress-bar-909105/)

Syllinger 10-20-2011 01:58 AM

How do I do other tasks in the background, and transfer files with a progress bar?
 
Hello Gents,

Alright, so first and foremost I figured out (kinda) how to trasnfer files using rsync, and it provides me with the progress of each file as it transfers. That said, is there any way to have some kind of overall progress indicator with an ETA on the entire transfer as well as a transferred bytes/total bytes read-out?

The other thing I realized is that in Windows I am able to do multiple tasks at once. How am I able to do this in Linux?

Note that I'm running Ubuntu Server LTS 10.04 and I have no GUI installed. I use Putty to SSH admin the system in a Win 7 environment.

elliott678 10-20-2011 02:16 AM

Since you're working in terminal only, look into screen, it allows multitasking in a single virtual terminal.

fukawi1 10-20-2011 02:28 AM

You can start a process to the background by using an ampersand after the command, and you can bring it to the foreground with "fg"

ie:
Code:

~ $ dd if=/dev/zero of=/dev/null&
[1] 12213
~ $ fg
dd if=/dev/zero of=/dev/null
^C14008853+0 records in
14008852+0 records out
7172532224 bytes (7.2 GB) copied, 9.07019 s, 791 MB/s
~ $

You can also start a job normally, and then pause it, with ctrl+z and send it to the background or foreground using "fg" and "bg"
ie:
Code:

~ $ dd if=/dev/zero of=/dev/null
^Z
[1]+  Stopped                dd if=/dev/zero of=/dev/null
~ $ fg
dd if=/dev/zero of=/dev/null
^Z
[1]+  Stopped                dd if=/dev/zero of=/dev/null
~ $ bg
[1]+ dd if=/dev/zero of=/dev/null &
~ $ fg
dd if=/dev/zero of=/dev/null
^C12032378+0 records in
12032377+0 records out
6160577024 bytes (6.2 GB) copied, 17.2294 s, 358 MB/s

~ $

Or you can create another ssh session with putty, and work away in the new session..

Syllinger 10-20-2011 03:13 AM

Ahh, perfect. Thank you for the quick response. Just looked up the man pages/O'reilly entry on Job Control. The problem is that I didn't know what it was called, I assumed there was some kind of Windows Task Manager tool.

Thanks again!

Nylex 10-20-2011 03:15 AM

Quote:

Originally Posted by fukawi1 (Post 4503198)
Or you can create another ssh session with putty, and work away in the new session..

This is unnecessary. You can just use Screen, as elliott678 pointed out.

16pide 10-20-2011 03:38 AM

I personally use gnome-terminal for my command line activity.
I use tabs to separate my activities.
With this I haven't needed background processes. But yes, &, bg, fg are your friends if you want to do that.
I don't use background processes much because it messes up the display (stdout of the background process messes display of whatever else you're doing in the shell. You could always redirect output to a file, but that's another story

fukawi1 10-20-2011 03:40 AM

Apologies, my earlier post should have added "if you want to view both outputs at once" in the sense of tailing log files while generating log entries (iptables + hping for example).

I wasn't aware if this was possible with screen or not..

inoculos 10-20-2011 01:38 PM

there is a terminal called terminator. It is a very good multitasking terminal.


http://www.tenshu.net/p/terminator.html

Syllinger 10-20-2011 09:00 PM

Quote:

Originally Posted by Nylex (Post 4503219)
This is unnecessary. You can just use Screen, as elliott678 pointed out.

Well, if I were logging directly into the server, I don't think it would be unnecessary. I would only have one command prompt, so I figure that using Job Managment would be useful in that instance.

Also, I don't understand how to use screen with Putty. It seems very complicated when compared to Job Managment, and it does the exact same thing. You are still able to monitor silence and output with Job Managment, or at least, that's what the man pages suggest.

fukawi1 10-20-2011 09:52 PM

Quote:

Originally Posted by Syllinger (Post 4503926)
Well, if I were logging directly into the server, I don't think it would be unnecessary. I would only have one command prompt, so I figure that using Job Managment would be useful in that instance.

If by "directly" you mean, physically sitting at the machine, you can generally switch between console by pressing ctrl + F[1-8].

Nylex 10-21-2011 01:12 AM

Quote:

Originally Posted by Syllinger (Post 4503926)
Also, I don't understand how to use screen with Putty. It seems very complicated when compared to Job Managment, and it does the exact same thing.

Screen has nothing to do with PuTTY. You just run "screen" at the command prompt. It isn't any more complicated than if you had a graphical terminal window with multiple tabs (or even a web browser with multiple tabs). Ctrl-a c will create new windows and you can cycle through them with Ctrl-a n (to go forwards) and Ctrl-a p (to go backwards). Each window has an associated number (starting from 0), so you can access it directly with Ctrl-a x, where x is the number. You can also get the list of windows with Ctrl-a ".

Syllinger 10-21-2011 01:39 AM

Quote:

Originally Posted by Nylex (Post 4504026)
Screen has nothing to do with PuTTY. You just run "screen" at the command prompt. It isn't any more complicated than if you had a graphical terminal window with multiple tabs (or even a web browser with multiple tabs). Ctrl-a c will create new windows and you can cycle through them with Ctrl-a n (to go forwards) and Ctrl-a p (to go backwards). Each window has an associated number (starting from 0), so you can access it directly with Ctrl-a x, where x is the number. You can also get the list of windows with Ctrl-a ".

Well, that's a much better explanation than most of the man pages, and even guides, have given. Thanks.

Still, I'm always hearing about Linux security, and why would you want to install something like screen when you can simply use Job Management?

I'm not trying to be argumentative, I'm just saying that when it comes to Linux there are several ways to solve a problem, and you choose the one that you find the simplest and most convenient. Just trying to understand why someone would choose something like that over Job Management, which seems easy enough to use.

Still, I'll give screen a look. Definitely sounds promising, but it sounds like it would use a decent chunk of memory as well.

Thanks for the help guys. As always, it's very much appreciated.

Nylex 10-21-2011 02:15 AM

I find the manual (on the GNU website, not the man page) for Screen quite good.

Your question is a sensible one. Say one of the things you wanted to do at the terminal was to log into another machine with ssh. You can't send Ctrl-Z to suspend the ssh process (so you can e.g. run "bg"), as it will be sent to the shell that's running remotely.

Another reason for using Screen is that you can detach your session. OK, this has nothing to do with job management, but it's a useful feature. Say you wanted to log into another machine and run some long running program there. If your connection to that machine dies, then your program may die too (I'm not sure exactly what determines whether it does or not. I did a quick (and very unscientific) test and a program I was running didn't die. Odd.). With Screen, detaching the session and logging out won't kill your program.

I'm sure there are other good reasons, too, but those are the (important) ones that I use Screen for.

Syllinger 10-21-2011 02:47 AM

So how do I try this out?

sudo apt-get install screen?

Or do I need to add any repos?

I'm using Ubuntu Server LTS 10.04.

Also, I still very much feel like a beginner when it comes to Linux. I'm sure there's a lot of use for it. I just find that amongst the server folk, adding additional (especially memory intensive) software packages is frowned upon.

There is really no reason to use best practices in my situation. But, it's always nice to know how to do something with a stock install, rather than relying on software tools.

I'm sure there are other applications for screen that will become readily apparent as I continue to dabble within the OS.

That said, you mentioned that you can't open a new SSH session using Job Managment, but there would be little reason if you are connected locally. Also, using Job Managment remotely, a SSH connection would already be established, you're just arranging which jobs are running in the foreground/background.

Still, I imagine things would get dicey if you were looking to log in as different users.

Nylex 01-21-2012 12:26 AM

Sorry, haven't been at LQ that much recently. Screen should be in the standard repository.


All times are GMT -5. The time now is 07:06 PM.