ONO::Cron::Service::Weekly

package ONO::Cron::Service::Weekly;
################################################################################
# COPYRIGHT / LICENSE #
################################################################################
#
# This file is part of the ONO Software Project.
#
# Copyright (C) 2000-2025 Jos KIRPS [ www.kirps.com | jos_AT_kirps_DOT_com ]
# and The Joopita Project [ www.joopita.org | contact_AT_joopita_DOT_com ]
#
# This file, as well as other parts of the ONO Software Project or related
# elements, are FREE SOFTWARE available under the ARTISTIC LICENSE 2.0.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# For the full license, see /ono/osr/license/LICENSE.txt, or write to
# jos_AT_kirps_DOT_com or contact_AT_joopita_DOT_com.
#
################################################################################
# END OF COPYRIGHT / LICENSE, HERE COMES THE CODE ... #
################################################################################

use strict;

use ONO::IO;

use ONO::Cron::Service::ToolBox;

###############################################################################
# ONO
###############################################################################

#: ONO Cron Service weekly tasks.

sub run {

#: Execution logic.

my (
$self,
$db,
$sec,$min,$hour,
$mday,$mon,$year,
$wday,$yday,$timestamp,
$switches,
) = @_;

my $DATA = ONO::Cron::Service::ToolBox->print("Service running: Weekly",$switches);

$DATA .= ONO::Cron::Service::ToolBox->print("- n/a",$switches);

############################################################################
# clean up /tmp/var/
############################################################################

$DATA .= ONO::Cron::Service::ToolBox->print("- clean up /tmp/var/",$switches);

foreach my $subdir (ONO::IO->dir("tmp/var")) {
if ($subdir !~ /\./ && $subdir =~ /[a-z]/) {
foreach my $file (ONO::IO->dir("tmp/var/$subdir")) {
if ($file !~ /^\./ && $file =~ /[a-z]/) {
if ($file =~ /\./) {

# clean up /tmp/var/subdir

ONO::IO->rm("tmp/var/$subdir/$file");

} else {

# clean up /tmp/var/subdir/subdir2

foreach my $file2 (ONO::IO->dir("tmp/var/$subdir/$file")) {
if ($file2 !~ /^\./ && $file2 =~ /\./ && $file2 =~ /[a-z]/) {
ONO::IO->rm("tmp/var/$subdir/$file/$file2");
}
}

ONO::IO->rmdir("tmp/var/$subdir/$file");

}
}
}
ONO::IO->rmdir("tmp/var/$subdir");
}
}

############################################################################
# done
############################################################################

return $DATA;

}

###############################################################################
# end of script
###############################################################################

1;

__END__