CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
cron job, perl script, mysql backup



Jun 18, 2001, 8:34 AM

Post #1 of 1 (613 views)
cron job, perl script, mysql backup Can't Post

I would like to set a cron job to backup my mysql database. I don't want to put my password in the cron job as that makes it public. I would like to create a perl script and call it from cron. I am not sure how to write the perl script. Here is what I have so far, but it doesn't seem to work. Is system() the right function to use? Am I missing something else? (Watch the word wrap and, btw, I sanitized the host, username, password, etc.)

$| = 1;
print "Content-type: text/html\n\n";

$dstamp = &dstamp;
$cmd = "/usr/bin/nice -20
/usr/local/bin/mysqldump --quick -username -ppassword username_databasename > backup/test.$dstamp.sql";

sub dstamp {
local ($day,$mon,$year,$z1,$z2);
$z1 = $z2 = "";
(undef,undef,undef,$day,$mon,$year,undef,undef,undef) = localtime(time);
$year += 1900;
if ($mon<10) { $z1 = '0'; }
if ($day<10) { $z2 = '0'; }
return "$year$z1$mon$z2$day";


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives