frank1 has asked for the wisdom of the Perl Monks concerning the following question:
the below script works successfully on backup the database
the only problem i have is to remove the files which are modified or uploaded on server 30 minutes ago
i want to backup the database and then remove all files ending .sql which are stored or uploaded on server 30minutes ago
#!/usr/bin/perl use strict; use warnings; use File::stat; use POSIX qw(strftime); my $dbhost = ''; my $dbuser = ''; my $dbname = ''; my $folder = 'backup/'; my $filename = join '.', 'db.backup', time, 'sql'; if ($bp = `mysqldump --host=$dbhost --user=$dbuser --password="dbpassw +ord" $dbname > $folder$filename`) { for my $file(@$folder) { my $time = (stat($file))[9]; my $mod_time = strftime('%M', localtime($time)); if ($mod_time > '30') { unlink glob "$folder/*.sql"; } } } else { die "error"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: unlink files
by Corion (Patriarch) on Aug 07, 2024 at 18:10 UTC | |
|
Re: unlink files
by NERDVANA (Priest) on Aug 07, 2024 at 17:34 UTC | |
|
Re: unlink files
by cavac (Prior) on Aug 08, 2024 at 13:27 UTC | |
|
Re: unlink files
by karlgoethebier (Abbot) on Aug 07, 2024 at 13:53 UTC | |
by frank1 (Monk) on Aug 07, 2024 at 15:20 UTC | |
by karlgoethebier (Abbot) on Aug 07, 2024 at 17:07 UTC | |
by frank1 (Monk) on Aug 07, 2024 at 17:41 UTC | |
by Corion (Patriarch) on Aug 07, 2024 at 18:11 UTC | |
|
Re: unlink files
by Anonymous Monk on Aug 07, 2024 at 17:32 UTC | |
by frank1 (Monk) on Aug 07, 2024 at 18:26 UTC | |
|
Re: unlink files
by perlfan (Parson) on Aug 24, 2024 at 17:36 UTC |