Rt-shredder & bash script

Hi

Noob question here.
Trying to use rt-shredder from a bash script using a bash date variable
to wipeout tickets but shredder seems to ignore my date parameter which
I assume is because its badly formatted.

Have gotten this to work using a fixed date/time -

/#!/bin/sh//
//filename=date +%Y%m%dT%H%M%S-0001.sql//
///opt/rt4/sbin/rt-shredder --sqldump
/opt/stf/backups/rt-shredder/$filename --force --plugin Ti//
//ckets=query,"(Queue = ‘Supplier invoices’) AND status = ‘resolved’ AND//
// resolved > ‘2016-08-01 00:00:00.00’ ;limit,2000"/

but I would like it to work like this -

/#!/bin/sh//
//filename=date +%Y%m%dT%H%M%S-0001.sql//
//cutoff=date +%Y-%m-%d --date='2 years ago'//
//cutoff="’$cutoff 00:00:00’"//
//echo $cutoff//
///opt/rt4/sbin/rt-shredder --sqldump
/opt/stf/backups/rt-shredder/$filename --force --plugin Ti//
//ckets=query,"(Queue = ‘MCL - Supplier invoices’) AND status =
‘resolved’ AND resolved > $cuto//
//ff ;limit,2000"/

Is this possible from a bash script, any help greatly appreciated.

Kind Rgards
TomC

Hi

Noob question here.
Trying to use rt-shredder from a bash script using a bash date variable to
wipeout tickets but shredder seems to ignore my date parameter which I
assume is because its badly formatted.

Have gotten this to work using a fixed date/time -

#!/bin/sh
filename=date +%Y%m%dT%H%M%S-0001.sql
/opt/rt4/sbin/rt-shredder --sqldump /opt/stf/backups/rt-shredder/$filename
–force --plugin Ti
ckets=query,“(Queue = ‘Supplier invoices’) AND status = ‘resolved’ AND
resolved > ‘2016-08-01 00:00:00.00’ ;limit,2000”

but I would like it to work like this -

#!/bin/sh
filename=date +%Y%m%dT%H%M%S-0001.sql
cutoff=date +%Y-%m-%d --date='2 years ago'
cutoff=“‘$cutoff 00:00:00’”
echo $cutoff
/opt/rt4/sbin/rt-shredder --sqldump /opt/stf/backups/rt-shredder/$filename
–force --plugin Ti
ckets=query,“(Queue = ‘MCL - Supplier invoices’) AND status = ‘resolved’ AND
resolved > $cuto
ff ;limit,2000”

I believe shredder will respect relative time constraints:

1 day ago

etc.

You could try passing a relative date to shredder (thus bypassing the
call to date) and seeing if that works.

-m