#!/usr/bin/python import os import time source=['/root/perl-demo','/root/perl-gongju'] target_dir='/root/backup/' target=target_dir+time.strftime('%Y%m%d%H%M%S')+'.zip' zip_command="zip -qr '%s' %s" % (target,' '.join(source)) if os.system(zip_command)==0: print 'OK!',target else: print 'NO'