Linux - SoftwareThis 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.
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.
Is there a way to kill rsync so than no temporal files will be left behind?
For example, when I'm transferring test.bin from one folder to another, and rsync is killed, it leaves behind a file named .test.bin.4IOU9 I want rsync to delete that file when it's killed.
Well, kill it nicely then. If you're just abruptly killing it by doing a ctrl-c or the like, if the process is gone, how's it suppose to clean up after itself? I've never tried but while it's copying or running, try sending a kill -15 to the process and see if that allows it to clean up the leftovers that were partially copied.
Problem is than I'm using rsync to copy about 100GB of data. This will take several days, as the connection speed is really slow.
This can only be done at nights, so I have CRON launching a bash script, which launches the rsync. This script has to end exactly at 8:00 in the morning, so CRON launches another script at that time to stop the first one.
Rsync copies whole folders, so I can't ask it to end between two individual files, so I assume my only chance is to kill it. I tried with kill -15 and it also leaves the temp file behind. I tried with some other signals, but all yield the same result.
How exactly does cron stop the running rsync? You don't kill -9, do you?
In my experience, Ctrl+C or kill -15 get the same clean result because the program IS able to react to both BEFORE leaving. Not a single chance with kill -9 though.
Distribution: Slackware & Slamd64. What else is there?
Posts: 1,705
Rep:
Instead of killing it in the middle, and having it possibly never finish, leaving you with perpetually unbacked-up files why don't you create a PID file in /tmp? The script should check for the existence of this file and if it exists then don't start a new instance.
This is what I do for my cron jobs.
Edit: I realize you don't want it to continue running after 8:00 A.M. I still think this isn't what you really want if you can't copy everything. Can't you let it finish? BTW, after it finishes once it will be alot faster the next time. rsync is smart about not copying stuff that exists on the receiving end.
At 8 AM, people start working, and they need the internet connection to be free, as it is already very slow, that's why I have to stop it even if it is in the middle of transferring a file.
I only need this working for the next 2-3 weeks, since when the synchronization finishes, it will only take a few hours to copy the new files added that day.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.