rclone icon indicating copy to clipboard operation
rclone copied to clipboard

add ability to signal rclone to finish current partial task and exit

Open trapexit opened this issue 8 years ago • 9 comments

It'd be convenient to be able to signal rclone (perhaps via a SIGUSR1 or SIGUSR2?) to finish up working on the current transfers and then exit so uploads aren't left in a half state. Or perhaps SIGINT? One ctrl-c on the terminal or from external source could tell it to finish up and exit while a second SIGINT would instruct it to exit immediately.

trapexit avatar Dec 20 '16 21:12 trapexit

Nice idea.

ncw avatar Dec 21 '16 12:12 ncw

+1

martinbowling avatar Dec 22 '16 00:12 martinbowling

I agree. If you issue the "brake" command you could be presented with, "finish task or abort" this suggestion for those of us who use key strokes or what not to control our screen sessions.

Anothr thing, finish task could be keyed to f and abort could be keyed to a or something like that.

marrie avatar Dec 28 '16 19:12 marrie

Yes please!

kk7ds avatar Jan 26 '17 22:01 kk7ds

For interactive use I think the first Ctrl+C (SIGINT) for soft abort and second for hard abort works best. For non-interactive use one could probably just send SIGINT for soft abort and SIGTERM for hard abort.

felixbuenemann avatar Apr 01 '17 13:04 felixbuenemann

I adhere to this feature request. Another approach could be to put some "flag" that could be read from time to time, for example if you put a file in the same folder where rclone.exe resides, named stop.txt, after X minutes Rclone could look up if there is the file and then to gracefully stop after end the current file being transfered. Maybe is not the most elegant solution but it's handy.

roberdaniel avatar Sep 28 '19 01:09 roberdaniel

This could be an API call too...

ncw avatar Sep 28 '19 10:09 ncw

This would be a great feature to have for some use cases here; I suggest implementing it via the remote control server (ie, --rc) functionality.

DurvalMenezes avatar Aug 20 '20 14:08 DurvalMenezes

I was able to figure out a workaround using socat as a “session manager” for graceful shutdown. example:

rclone serve sftp --addr :8022 local:/my_dir/ can be used to host the /my_dir folder with SFTP socat TCP-LISTEN:2022,fork,reuseaddr TCP-CONNECT:127.0.0.1:8022 was used to proxy connections to the real rclone instance.

socat would start with a certain pid (eg. 150) when an sftp session was opened, socat would “move” the traffic proxy into a new process (eg. 151). Then a SIGTERM signal could be sent to the original process (150) and the container would stop accepting new connections. The child processes can then be monitored using something like ps and will stay open until the client disconnects. Once that happens, the rclone process can be safely terminated.

Here's a gist with a basic script that does this: https://gist.github.com/ColinHeathman/ffd441f292a1e42c92835b6d639ec5a5

ColinHeathman avatar Aug 15 '22 17:08 ColinHeathman