Skip to content

Instantly share code, notes, and snippets.

@cocoa1231
Created March 15, 2020 11:47
Show Gist options
  • Save cocoa1231/40b2036be39010bfa1a8170116596a65 to your computer and use it in GitHub Desktop.
Save cocoa1231/40b2036be39010bfa1a8170116596a65 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import os
users = [filename for filename in os.listdir('/var/cpanel/users') if os.path.isfile(filename)]
batches = ['server8.flaunt7.com', 'server9.flaunt7.com', 'server10.flaunt7.com']
def chunks(lst, n):
for i in range(0, len(lst), n):
yield lst[i:i+n]
chunked_users = chunks(users, len(batches))
for i, userlist in enumurate(chunked_users):
with open(batches[i], 'w') as f:
f.write('\n'.join(userlist))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment