Skip to content

Instantly share code, notes, and snippets.

@ionox0
Last active January 27, 2020 15:53
Show Gist options
  • Save ionox0/a957d075c7b43c554ba2433e803fa45a to your computer and use it in GitHub Desktop.
Save ionox0/a957d075c7b43c554ba2433e803fa45a to your computer and use it in GitHub Desktop.
Script to copy a bunch of folders using bsub
# Uses bsub with rsync to copy large folders
#
# Uses a walltime limit of 60 hours (should be enough for very large folders)
#
# Runs in parallel across each subfolder of the source folder, and creates logs for each as well
#
# Usage: python bsub_copy.py /source/folder /dest/folder
import os
import sys
import subprocess
# Put the base of the source folder here
source_base = sys.argv[1]
# Put the destination folder here
dest_base = sys.argv[2]
# Fill this with folders from `source_base` above
source_folders = os.listdir(source_base)
for src in source_folders:
cmd = [
'bsub',
# Set a high walltime
'-W 3600',
'-eo',
'{}_err.log'.format(src),
'-oo',
'{}_out.log'.format(src),
'rsync -azvh {}/{} {}'.format(source_base, src, dest_base)
]
subprocess.call(cmd)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment