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

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

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

 



kenvogt
Deleted

Jun 18, 2001, 8:34 AM

Post #1 of 1 (293 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.)

#!/usr/bin/perl
$| = 1;
print "Content-type: text/html\n\n";

$dstamp = &dstamp;
$cmd = "/usr/bin/nice -20
/usr/local/bin/mysqldump --quick -hdbxx.pair.com -username -ppassword username_databasename > backup/test.$dstamp.sql";
system($cmd);
exit;

sub dstamp {
local ($day,$mon,$year,$z1,$z2);
$z1 = $z2 = "";
(undef,undef,undef,$day,$mon,$year,undef,undef,undef) = localtime(time);
$mon++;
$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