Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've just started using lftp for remote transferring files on my Raspberry Pi running Debian. I know how to transfer the files, and use queue and jobs to add and view transferring files.

However, I'm not actually sure on how to view these transfers once lftp moves to the background. The lftp man page mentions how lftp is moving to the background, but when I open a new instance of the program from shell and type jobs, the queue is empty. However, I can clearly see using my file manager that the transfers are still happening, as the files are there and growing in size.

I'm guessing that when I reopen lftp, it's just opening a new instance that isn't connected to the nohup mode lftp that has the active queue. I've tried searching various places, but no one else seems to have this particular issue.

So, I guess what I'm asking is twofold:

  1. Is there a way to easily attach to the background lftp process to view the current jobs list?

  2. If not, is there a way to view this at all?

share|improve this question

3 Answers 3

up vote 5 down vote accepted

You are correct that instances of lftp do not share the job queue, which is of course similar to how shell job queue works.

Still, lftp can indeed attach to an existing backgrounded session. According to lftp news version history, the feature was introduced in version 4.3.0 (2011-06-17). If your connection to lftp session disconnects or you exit with backgrounded transfers ongoing, with recent versions you can still resume the backgrounded lftp process and get access to its job queue.

From lftp man page:

attach [PID]

Attach the terminal to specified backgrounded lftp process.

To do this you need to know the process id, PID, of the backgrounded lftp process. A simple way to do this is the pgrep command, which lists matching process IDs.

For example, here I background a transfer in lftp:

lftp remote:/path> get oi-dev-151a-x86.iso 
[0] get oi-dev-151a-x86.iso &                                             
     `oi-dev-151a-x86.iso' at 655360 (0%) 296.1K/s eta:46m [Receiving data]
lftp remote:/path> exit
[82106] Moving to background to complete transfers...

This lists the pid needed to attach, but in case we did not have this noted down, we can find it again with pgrep:

$ pgrep lftp
82106

And here we resume the backgrounded lftp:

$ lftp
lftp :~> attach 82106
[82106] Attached to terminal.
lftp remote:/path> jobs
[0] get oi-dev-151a-x86.iso 
    `oi-dev-151a-x86.iso' at 42827776 (5%) 1.49M/s eta:10m [Receiving data]

The Debian stable version might not have the attach feature though, but you can still list the active lftp processes with pgrep.

share|improve this answer
    
This is absolutely correct, though I'm very late commenting on that fact. Thank you very much. For those that come along later, pgrep actually did not work for me. I had to use "ps aux | grep lftp", as (for some reason) pgrep would sometimes not return a value when lftp was certainly running and found with ps aux. –  drpfenderson Jul 12 at 20:42

From the lftp man page:

If  you exit lftp when some jobs are not finished yet, lftp will move itself to
nohup mode in background. The same happens when you have a real modem hangup or
when you close an xterm.

You cannot connect to background processes running with nohup if the parent process has terminated.

share|improve this answer

Collected from the lftp man page: Use ctrl-z to move the process in background and exit lftp, later start lftp again and type wait.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.