Logout script - delete a file

Good evening you scripting guru's!

I have the following script to delete a file on logout of a Mac :

find  . �name com.apple.sidebarlists.plist �exec  rm  -f {} \;

It works fine in terminal and when logging out. However, it takes forever to run the script at logout...A minute and a half.

Is there a way to just run the command and targeting the current directory it is contained in? What would the syntax be to search the directory Library/Preferences?

Thanks,
AG

perhaps you could try:

nohup find . -name "com.apple.sidebarlists.plist" �exec rm -f {} \; &

If you already know the file's name and location, why don't you just remove it :confused:

Deleting is the easy part....
History of this:
We run an AD environment with MACs running 10.3.9 and 10.4.11

The com.apple.sidebarlists.plist sets up differently when logging onto either OS. So, when you go back and forth between OS's - A volume error occurs. Apple has confirmed this issue.

Their suggestion was to write a script to delete the file at logout.

The script above actually works, but thier is a lag time when logging out.

I tried the nohup command, but so far it hasn't worked for a user connected to the server.

Using the (find . -name) searches through all files on the drive before hitting the correct file to delete. (SLOW)

I have tried find ./Library in the sh but it only works in terminal and will not work when logging out.

Is there a variable in which I can put into the script that will go directly to the file and delete it?

Thanks for any suggestions.

AG

You need to give absolute path in the find command, like

find /var/lib -name 'NAME'

It seems like, it takes time for searching in many places to delete, so you can use absolute path, and let us know.

Also, there is a useful option -xdev in "find", which will be of great use to you if you have multiple filesystems and wasting time in other places.

What is the absolute pathname of: Library/Preferences ?

Is the file stored in different locations between the osx versions?

sw_vers -productVersion will give you the major minor and patch level.

OSXVER=`sw_vers -productVersion | awk -F. '{print $1 "." $2}'`

I use the above variable to run different script stuff against different osx versions. Since they all seem to be different and require specific scripts for each one :rolleyes:

find ~ . -name com.apple.sidebarlists.plist -exec rm -f {} \;

The above worked- the ~ helped to search only the users folder. Note: these are users' on the network that connect to Mac server.

Now- for the logon script...I need to also delete the file at logon..The initial script works at logon but slowly- it eventually gets to the home folder to delete, but need it faster.
Any suggestions? I will post once I figure out the solution today.

Thanks....AG

---------- Post updated at 11:20 PM ---------- Previous update was at 06:41 AM ----------

any way to run the script in the background so the user does not have to wait for it to process?

Thanks

check out the

nohup ... &

construction earlier in this thread

Hi

This should work

find ~ . .name com.apple.sidebarlists.plist .exec rm -f {} \; &

So I am basically running this ..

Login.sh

/Library/Directory/login1.sh &

Login1.sh

find ~ . -name com.apple.sidebarlists.plist -exec rm -f {} \;

This does not hang up on login, however, after system logon, it will take 30 seconds to delete the file....I need it done immediately after logon..I cannot have a delay.
Any thoughts?

When using & - how can you stop it from processing..You need to go into terminal for it to complete..

Can you execute a rm command within a script to speed up the process?

Can the file be locked at login, how do you free it up to delete?