Sponsored Content
Operating Systems OS X (Apple) Startup script to clean out trash can Post 302093473 by [MA]Flying_Meat on Thursday 19th of October 2006 03:34:21 PM
Old 10-19-2006
A login or logout hook could do this pretty easily.
Check out bombich.com for information about login/out hooks.

Basically the login hook mechanism puts the username into $1.
In pseudo code, the code to add to the login hook would go:
If "$1" equals studentusername
then rm -r /Users/studentusername/.Trash/*
End If

The system runs login hooks with root privs, so there should not be any access problem for the directory.
Admin privs (sudo) are required to add or remove login/out hooks. The script should be rwx for root only and stored in a directory with, at best, only root access.

A login or logout hook is really just a preference setting that points to a script to run (if I recall correctly). Well, that and some code some where responsible for passing the username to the script. Smilie

It should be said that the root account does not have to be enabled at all to create and use this hook functionality.
It can be a pretty powerful tool, and as with all powerful tools, test, test, test, then implement. Smilie
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

writing script to clean up a directory

I have to do a directory clean up on several machines. The task is as follows: go to a particular directory (cd /xxx) 1. create a directory ' SCRIPTCLEANUP ' ( i KNOW IT) loop through 2. List the directory 3. if directory and start with 'DQA' leave it, 4. if directory or file move it to... (0 Replies)
Discussion started by: ajaya
0 Replies

2. Shell Programming and Scripting

clean up script

I have a script which would monitor a given directory and delete any files which are older than 10 days. I was going to set the 10 crob jobs to perform this operation for 10 different directories (some are actually sub-directories), but my boss doesn't like that idea, so I need to do that in one... (1 Reply)
Discussion started by: mpang_
1 Replies

3. Solaris

Script for automatic deletion of trash file of mail server

Hi, I have a mail server with limited space and operating system is sun solaris 8 (sparc). I do not have provisions to increase the space for home directory. So i have to delete files from /home/username/mail/trash which are more than 10 days old automatically. So my script should be like... (1 Reply)
Discussion started by: crown2100bd
1 Replies

4. Shell Programming and Scripting

How to clean this script?

Hello guys, this script partially works but it's still pretty ugly and, moreover, if the month is jan/feb/mar... it doesn't work at all. Could anyone say me how to correct, cut and clean a little bit? #!/usr/bin/ksh egrep -v -e "^\s*#" /file/permission | awk '{ print $1 }' | sort | uniq... (3 Replies)
Discussion started by: gogol_bordello
3 Replies

5. Shell Programming and Scripting

Script to FTP,clean up and email

Hi i need a unix script to do the following tasks. My folder structure is /home/MSTR/test and will have the following folder within it Cache Lookup Source Target 1. On the Source & Target folder i have to take a copy of files older than 5 days and move(FTP) it into local machines C:\Backup... (1 Reply)
Discussion started by: Codesearcher
1 Replies

6. Shell Programming and Scripting

Need a shell script to clean data

Hi, Appreciated if anyone can throw some hint I have a file format like this: old(1): PRCNCP 1 old(2): PRSKU ... (6 Replies)
Discussion started by: netbanker
6 Replies

7. Shell Programming and Scripting

Apache tomcat startup script not booting at startup.

I copied the script from an AskUbuntu post - #!/bin/bash ### BEGIN INIT INFO # Provides: tomcat7 # Required-Start: $network # Required-Stop: $network # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start/Stop Tomcat server ### END INIT INFO ... (14 Replies)
Discussion started by: Hijanoqu
14 Replies

8. UNIX for Dummies Questions & Answers

'awk' help for script to clean out wireless.

I've been working on a script to clean out the wireless connections on my MAC. I know the terminal command to do this (that part is not rocket science ;) ) So I thought I would have a go at automating this but I'm having trouble with the 'awk' command & the correct context. My code is := ... (7 Replies)
Discussion started by: Lord Lien
7 Replies

9. UNIX for Beginners Questions & Answers

UNIX Script to clean files

Hello All, I need a script that would delete files which are more than "X" number of days old, also if there can be a log file of the deleted files for reference. I am from windows background hence finding it difficult. Any help is much appreciated Regards Wert (4 Replies)
Discussion started by: wert468
4 Replies
SHUTDOWNHOOK_ESTABLISH(9)				   BSD Kernel Developer's Manual				 SHUTDOWNHOOK_ESTABLISH(9)

NAME
shutdownhook_establish, shutdownhook_disestablish -- add or remove a shutdown hook SYNOPSIS
void * shutdownhook_establish(void (*fn)(void *), void *arg); void shutdownhook_disestablish(void *cookie); DESCRIPTION
The shutdownhook_establish API is deprecated. The shutdownhook_establish() function adds fn to the list of hooks invoked by doshutdownhooks(9) at shutdown. When invoked, the hook func- tion fn will be passed arg as its only argument. The shutdownhook_disestablish() function removes the hook described by the opaque pointer cookie from the list of hooks to be invoked at shutdown. If cookie is invalid, the result of shutdownhook_disestablish() is undefined. Shutdown hooks should be used to perform one-time activities that must happen immediately before the kernel exits. Because of the environ- ment in which they are run, shutdown hooks cannot rely on many system services (including file systems, and timeouts and other interrupt- driven services), or even basic system integrity (because the system could be rebooting after a crash). RETURN VALUES
If successful, shutdownhook_establish() returns an opaque pointer describing the newly-established shutdown hook. Otherwise, it returns NULL. EXAMPLES
It may be appropriate to use a shutdown hook to disable a device that does direct memory access, so that the device will not try to access memory while the system is rebooting. It may be appropriate to use a shutdown hook to inform watchdog timer hardware that the operating system is no longer running. SEE ALSO
doshutdownhooks(9) BUGS
The names are clumsy, at best. BSD
May 14, 2009 BSD
All times are GMT -4. The time now is 02:40 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy