Skip to content

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

Open

Description

@trapexit

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.

Activity

  1. ncw commented on Dec 21, 2016

    @ncw
    Member

    Nice idea.

  2. martinbowling commented on Dec 22, 2016

    @martinbowling

    +1

  3. marrie commented on Dec 28, 2016

    @marrie

    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.

  4. kk7ds commented on Jan 26, 2017

    @kk7ds

    Yes please!

  5. felixbuenemann commented on Apr 1, 2017

    @felixbuenemann
    Contributor

    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.

  6. added this to the Help Wanted milestone on Dec 14, 2017
  7. roberdaniel commented on Sep 28, 2019

    @roberdaniel

    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.

  8. ncw commented on Sep 28, 2019

    @ncw
    Member

    This could be an API call too...

  9. DurvalMenezes commented on Aug 20, 2020

    @DurvalMenezes
    Contributor

    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.

  10. ColinHeathman commented on Aug 15, 2022

    @ColinHeathman

    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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions