$theTitle=wp_title(" - ", false); if($theTitle != "") { ?>
About Virtualization, VDI, SBC, Application Compatibility and anything else I feel like
I needed to delete around 50 scheduled tasks from several machines in Altiris because something went wrong in on of the first jobs.
It would have better if the jobs were configured to fail on error and not continue but they weren’t.
Deleting the jobs from the Altiris console is very, very, slow. First the console asks for confirmation (after showing the hourglass for a long time):
Then the actual delete can take a few minutes and then the next server and so on.
I decided to delete the tasks directly from SQL.
I know this is not preferred but I think in the end it’s safe enough because I found a stored procedure called del_event_schedule which looks like this:
1 2 3 4 5 6 7 8 9 10 11 | ALTER procedure [dbo].[del_event_schedule] @schedule_id int as begin transaction delete from event_schedule where schedule_id = @schedule_id if (@@error != 0) rollback transaction else commit transaction |
So al it does is a (transacted) delete from the table.
First I created a query that selects the current scheduled tasks:
1 2 3 4 5 6 7 | SELECT computer.name, event.name FROM dbo.event_schedule INNER JOIN dbo.computer ON dbo.computer.computer_id = dbo.event_schedule.computer_id INNER JOIN dbo.event ON dbo.event_schedule.event_id = dbo.event.event_id WHERE dbo.computer.computer_name like 'VCTXA070%' AND dbo.event_schedule.status_code is null AND event_schedule.start_time is not null |
This selects the computer name and task name for all computers that match VCTXA070% that have not yet started (status_code is null).
The start_time check prevents deleting recurring tasks like this one:
Since this gave me the correct results I deleted them:
1 2 3 4 5 6 7 | DELETE FROM event_schedule FROM dbo.event_schedule INNER JOIN dbo.computer ON dbo.computer.computer_id = dbo.event_schedule.computer_id INNER JOIN dbo.event ON dbo.event_schedule.event_id = dbo.event.event_id WHERE dbo.computer.computer_name like 'VCTXA070%' AND dbo.event_schedule.status_code is null AND event_schedule.start_time is not null |
If you want to delete completed tasks as well you can just leave out the status_code check:
1 2 3 4 5 6 | DELETE FROM event_schedule FROM dbo.event_schedule INNER JOIN dbo.computer ON dbo.computer.computer_id = dbo.event_schedule.computer_id INNER JOIN dbo.event ON dbo.event_schedule.event_id = dbo.event.event_id WHERE dbo.computer.computer_name like 'VCTXA070%' AND event_schedule.start_time is not null |
One Response for "Deleting scheduled Altiris tasks from SQL"
Thanx man very useful post
Leave a reply