I need help modifying a script that triggers an email when a ticket remains 'new' for over two hours, to make it send automatically without manual updates.

Hello, I created the script in RT5 if the ticket is in new status more than 2 hours, it will trigger the email, however it is working only when there is any manual updates in tickets such as user comments, any updates in ticket , I need to trigger this mail automatically at regular interval…can you please help me how to work on this part??. Below is the custom condition script

Check if the ticket is in ‘new’ status and has been in this status for more than 2 hours

my $status = $self->TicketObj->Status;
my $created = $self->TicketObj->CreatedObj->Unix; # Time the ticket was created
my $now = time(); # Current time

Calculate time difference in seconds

my $time_difference = $now - $created;

7200 seconds is equivalent to 2 hours

if ($status eq ‘new’ && $time_difference > 7200) {
return 1; # Return true to trigger the notification
return undef; # Otherwise, do not trigger the notification

The scrips normally only trigger when there is a transaction made on a ticket (its created, a reply or comment is made, some custom field is changed, subject altered, people tweaked, etc). If you want to do something on a regular basis with human interaction with the ticket, you’ll need to look at the rt-crontool utility that you can run from cron on your server.