Python, subprocess, dump, gzip and Cron
vtians at gmail.com
Tue Jun 10 06:51:51 CEST 2008
On Jun 10, 2:37 pm, Aidan <awe... at gmail.com> wrote:
> I'm having a bit of trouble with a python script I wrote, though I'm not
> sure if it's related directly to python, or one of the other software
> The situation is that I'm trying to create a system backup script that
> creates an image of the system, filters the output though gzip, and then
> uploads the data (via ftp) to a remote site.
> The problem is that when I run the script from the command line, it
> works as I expect it, but when it is run by cron I only get a 20 byte
> file where the compressed image should be... does anyone have any idea
> as to why this might be happening? Code follows
> from subprocess import PIPE, Popen
> from ftplib import FTP
> host = 'box'
> filename = '%s.img.gz' % host
> ftp_host = '192.168.1.250'
> ftpuser, ftppass = 'admin', 'admin'
> dest_dir = '/share/%s' % host
> dump = Popen('dump 0uaf - /',shell=True,stdout=PIPE)
> gzip = Popen('gzip',shell=True,stdin=dump.stdout,stdout=PIPE)
> ftp = FTP(ftp_host)
> ftp.storbinary('STOR %s' % filename,gzip.stdout)
> print "Image '%s' created" % filename
> I appreciate all feedback. Thanks in advance.
it's possible that the cron doesn't have the environment variables you
have, especially $PATH. So the script failed to find the command it
need to create the image.
More information about the Python-list