Skip to main content

pkgacct set destination folder with variable date format

Comments

1 comment

  • ethical
    thanks a lot. I added in the code but i get the error that the directory could not be created? could it be because /backup already exists (its a mounted separate drive) also you have an extra } at the end there. actually i think i got it with this instead does this make sense?
    #!/usr/bin/perl BEGIN { unshift @INC, '/usr/local/cpanel'; } use Cpanel::Config::Users (); my @cpusers = Cpanel::Config::Users::getcpusers(); use Time::Piece; my $date = localtime->strftime('%Y-%m-%d'); my $backupdir = "/backup/" . $date . "/"; print $backupdir; mkdir $backupdir; foreach my $user (@cpusers) { my $cmd = "/scripts/pkgacct --skiphomedir $user $backupdir"; open my $OUTPUT, '-|', $cmd or next; while (<$OUTPUT>) { print $_; } close $OUTPUT or next; }
    thanks!
    0

Please sign in to leave a comment.