Logout script - delete a file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Logout script - delete a file
# 1  
Old 10-31-2009
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 :
Code:
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

Last edited by pludi; 11-01-2009 at 12:47 PM.. Reason: code tags, please...
# 2  
Old 10-31-2009
perhaps you could try:
Code:
nohup find . -name "com.apple.sidebarlists.plist" –exec rm -f {} \; &

# 3  
Old 11-01-2009
Quote:
Originally Posted by AGGreenLinux
Is there a way to just run the command and targeting the current directory it is contained in?
If you already know the file's name and location, why don't you just remove it Smilie
# 4  
Old 11-01-2009
delete file

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
# 5  
Old 11-02-2009
You need to give absolute path in the find command, like

Code:
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.
# 6  
Old 11-02-2009
What is the absolute pathname of: Library/Preferences ?
# 7  
Old 11-02-2009
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 Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. SCO

Logout automatically when exiting a script

Hi, I am using SCO Unix. I write a script to execute a program by calling exec program The script will check the program is still there or not, if not, then it will exit the script by calling exit So if I press DEL to quit the program, the script will exit, but it will logout... (6 Replies)
Discussion started by: dannychan
6 Replies

2. Shell Programming and Scripting

Login, excute command, logout Script Help

Good Evening all, After spending the last week or so reading many posts I decided to register and join in. This is my first post on the forum so please forgive me as im new to this, Im after some help in throwing together a quick basic script without using expect to change the password on several... (4 Replies)
Discussion started by: mutley2202
4 Replies

3. Red Hat

Need Script to ZIP/SAVE & then DELETE Log file & DELETE ZIPS older than 12 months

ENVIROMENT Linux: Fedora Core release 1 (Yarrow) iPlanet: iPlanet-WebServer-Enterprise/6.0SP1 Log Path: /usr/iplanet/servers/https-company/logs I have iPlanet log rotation enabled rotating files on a daily basis. The rotated logs are NOT compressed & are taking up too much space. I... (7 Replies)
Discussion started by: zachs
7 Replies

4. Shell Programming and Scripting

How to run script on logout ?

Hi Everybody, I want to run my own script on logout , i can use .bash_logout file... problem is this will work only for that particular user... i want to know the common file... so that script wil run for all the user... 2. How to run script on Shutdown ? Thanks in advance Anitha (4 Replies)
Discussion started by: anisn2002
4 Replies

5. OS X (Apple)

Login/Logout script

Dear readers I use SnowLeopard 10.6.2 and need to do some special tasks at login and logout of an sepcific user. My problem is, how do I send a string "login" respectively "logout" from computer "A", where the login/logout script runs, to computer "B" where some other tasks need to be done. ... (3 Replies)
Discussion started by: tthaler
3 Replies

6. UNIX for Advanced & Expert Users

logout script common for both Mac and Linux?

hi all , I need to run few commands on user logout. A non-root user should be able to edit that script which runs after logout. I need to make the solution both all Linux versions as well as Mac. Can any body help me in this regard. (0 Replies)
Discussion started by: harsha10
0 Replies

7. UNIX for Dummies Questions & Answers

run a script at logout

hi all , Need to a run a program on user logout (using GNOME log screen). Tried using .bash_logout for this purpose but that doesnt seem to work. Similar to .bash_logout is there any script /program which a normal user (other than root ) can edit and run it on their logout? can anybody... (0 Replies)
Discussion started by: harsha10
0 Replies

8. Shell Programming and Scripting

run a script on logout by a non-root user

hi , i need to run a script that delete files when i logout as a user other than root user . I have tried out using .bash_logout but that doesnt seem to work , so any alternative for this to be done. Thanks in advance, Harsha (6 Replies)
Discussion started by: harsha10
6 Replies

9. UNIX for Dummies Questions & Answers

Login and logout script

Hi all I know ho I can run a script when a user logs in, viz using the .login or .profile file, however what can I use to run a script when a user logouts ? Thanks J :confused: (1 Reply)
Discussion started by: jhansrod
1 Replies

10. UNIX for Dummies Questions & Answers

logout/shutdown script

I am running JDictd (http://www.informatik.uni-leipzig.de/~duc/Java/JDictd/) from tcsh in Terminal on Mac OS X (:=Darwin=FreeBSD/Mach). I am trying to get it to exit cleanly silently upon Mac OS X system shutdown. My idea was that if there was a logout script in FreeBSD (basically a script... (1 Reply)
Discussion started by: ropers
1 Replies
Login or Register to Ask a Question