View | Details | Raw Unified | Return to bug 13287
Collapse All | Expand All

(-)a/misc/cronjobs/crontab.example (-1 / +1 lines)
Lines 90-96 KOHA_CRON_PATH = /usr/share/koha/bin/cronjobs Link Here
90
16 1 * * * __KOHA_USER__ $KOHA_CRON_PATH/cleanup_database.pl --sessions --zebraqueue 10 --list-invites --temp-uploads
90
16 1 * * * __KOHA_USER__ $KOHA_CRON_PATH/cleanup_database.pl --sessions --zebraqueue 10 --list-invites --temp-uploads
91
91
92
# delete old purchase suggestions weekly. Replace XX with a number to define the age of suggestions to delete.
92
# delete old purchase suggestions weekly. Replace XX with a number to define the age of suggestions to delete.
93
@weekly	__KOHA_USER__  $KOHA_CRON_PATH/purge_suggestions.pl --days XX > /dev/null 2>&1
93
@weekly	__KOHA_USER__  $KOHA_CRON_PATH/purge_suggestions.pl --confirm --days XX > /dev/null 2>&1
94
94
95
# share_usage_with_koha_community.pl every months
95
# share_usage_with_koha_community.pl every months
96
0 0 1 * *  __KOHA_USER__ $KOHA_CRON_PATH/share_usage_with_koha_community.pl
96
0 0 1 * *  __KOHA_USER__ $KOHA_CRON_PATH/share_usage_with_koha_community.pl
(-)a/misc/cronjobs/purge_suggestions.pl (-27 / +15 lines)
Lines 18-27 Link Here
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
use utf8;
22
21
23
BEGIN {
22
BEGIN {
24
25
    # find Koha's Perl modules
23
    # find Koha's Perl modules
26
    # test carefully before changing this
24
    # test carefully before changing this
27
    use FindBin;
25
    use FindBin;
Lines 34-81 use C4::Suggestions; Link Here
34
use C4::Log;
32
use C4::Log;
35
use C4::Context;
33
use C4::Context;
36
34
37
my ( $help, $days );
35
my ( $help, $days, $confirm );
38
36
39
GetOptions(
37
GetOptions(
40
    'help|?' => \$help,
38
    'help|?' => \$help,
41
    'days=s' => \$days,
39
    'days:i' => \$days,
40
    'confirm'=> \$confirm,
42
);
41
);
43
42
44
my $usage = << 'ENDUSAGE';
43
my $usage = << 'ENDUSAGE';
45
This script delete old suggestions
44
This script deletes old suggestions
46
Parameters:
45
Parameters:
47
-help|? This message
46
-help|? This message
48
-days TTT to define the age of suggestions to delete
47
-days TTT to define the age of suggestions to delete
48
-confirm flag needed to confirm purge operation
49
50
The days parameter falls back to the value of system preference
51
PurgeSuggestionsOlderThan. Suggestions are deleted only for a positive
52
number of days.
49
53
50
Example:
54
Example:
51
ENDUSAGE
55
ENDUSAGE
52
$usage .= $0 . " -days 30\n";
56
$usage .= $0 . " -confirm -days 30\n";
53
57
54
# If this script is called without the 'days' parameter, we use the system preferences value instead.
58
# If this script is called without the 'days' parameter, we use the system preferences value instead.
55
if ( !defined($days) && !$help ) {
59
$days = C4::Context->preference('PurgeSuggestionsOlderThan') if !defined($days);
56
    my $purge_sugg_days =
57
      C4::Context->preference('PurgeSuggestionsOlderThan') || q{};
58
    if ( $purge_sugg_days ne q{} and $purge_sugg_days >= 0 ) {
59
        $days = $purge_sugg_days;
60
    }
61
}
62
60
63
# If this script is called with the 'help' parameter, we show up the help message and we leave the script without doing anything.
61
# If this script is called with the 'help' parameter, we show up the help message and we leave the script without doing anything.
64
if ($help) {
62
if( !$confirm || $help || !defined($days) ) {
63
    print "No confirm parameter passed!\n\n" if !$confirm && !$help;
65
    print $usage;
64
    print $usage;
66
    exit;
65
} elsif( $days > 0 ) {
67
}
68
69
if ( defined($days) && $days ne q{} && $days > 0 ) {
70
    cronlogaction();
66
    cronlogaction();
71
    DelSuggestionsOlderThan($days);
67
    DelSuggestionsOlderThan($days);
72
}
68
} else {
73
elsif (!defined($days)){
74
    print $usage;
75
}
76
elsif ( $days == 0 ) {
77
    warn "This script is not executed with 0 days. Aborted.\n";
78
}
79
else {
80
    warn "This script requires a positive number of days. Aborted.\n";
69
    warn "This script requires a positive number of days. Aborted.\n";
81
}
70
}
82
- 

Return to bug 13287