Hi all..logout script ,is possible?

Hi ,
actualy I have 5 iMac with snowleopard installed ,and an xServe with leopard server installed ,and I use
a long script on the server wich controll if every iMac is online ,and if it is ,mount a particular directory and launch
iBackup with the profile for that machine, the script also wait to iBackup to finish is job and then un-mount the directory and shutdown (via ssh) the remote machine…When done ,it starts with the second iMac…
If a iMac is not online the scripts go to the secondone.

This scrip is very complicated and probably the iMac wil became 10 instead of 5.

Is there a way to put a script that when the user shutdown is iMac?
if yes I want to setup ibackup for every machine to backup on a network disk and then shutdown the machine.

thanks

no one have idea?